Coder Social home page Coder Social logo

devsullo / ng2-stomp-over-websocket Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 16.0 20 KB

STOMP Over WebSocket service for angular2

Home Page: http://devsullo.com/github/angular2-stomp-over-websocket-service/

License: MIT License

JavaScript 68.82% TypeScript 31.18%
angular2 ng2 service socket sockjs sockjs-client stomp websockets

ng2-stomp-over-websocket's People

Contributors

devsullo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ng2-stomp-over-websocket's Issues

Invalid SockJS path 'info'

When host is configured , by default when connecting in request ' info' is append in request path, why?

In configuration should be :

host: hostname:port/endPoint

and then subscribe to topic on websocket

Regards, Tomaž

Error in angular 5

Hello, actually I'm working in an project with angular 5, before that I worked with angular 4. But I decided upgraded angular. However the following errors appeared. Does someone has a ide about that?.
Please I need your help.

ERROR in ./node_modules/ng2-stomp-service/dist/stomp.service.ts
Module build failed: Error: /home/jose/projects/OpenMDM-FrontEnd-master/node_modules/ng2-stomp-service/dist/stomp.service.ts is not part of the compilation output. Please check the other error messages for details.
at AngularCompilerPlugin.getCompiledFile (/home/jose/projects/OpenMDM-FrontEnd-master/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:649:23)
at plugin.done.then (/home/jose/projects/OpenMDM-FrontEnd-master/node_modules/@ngtools/webpack/src/loader.js:467:39)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
@ ./node_modules/ng2-stomp-service/index.js 2:20-51
@ ./src/app/devices/devices.module.ts
@ ./src/app/layout/shared/layout.module.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Reconnect handling

Hi @devsullo,

this module is really useful, thanks for it.
Please help me, how can i handle the reconnect situation?
My client lifecycle:

  1. connect
  2. subscribe
  3. connection lost (e.g.: backend error)
  4. reconnect
  5. -> and at this point i need to subscribe again.

--Ben

Compile error with Angular 6

ERROR in ./node_modules/ng2-stomp-service/dist/stomp.service.ts
Module build failed: Error: C:\workspace\spring-boot-angular2-stomp\src\main\ng\node_modules\ng2-stomp-service\dist\stomp.service.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library
repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (C:\workspace\spring-boot-angular2-stomp\src\main\ng\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:709:23)
at plugin.done.then (C:\workspace\spring-boot-angular2-stomp\src\main\ng\node_modules@ngtools\webpack\src\loader.js:41:31)
at process._tickCallback (internal/process/next_tick.js:68:7)

Problems with disconnect and reconnect

Hi,

I'm having an issue with re-connecting. In the web app I'm making, only one page needs a stomp connection. When the user enters that page a stomp connection is made and then a subscription is made. When the user leaves that page, unsubscribe is called, followed by a disconnect. When the user goes back to that page, an InvalidStateError is received when trying to subscribe again.
My code is shown below.

export class MyComponent implement OnInit, OnDestory {

    subscription: any;

    constructor(private stompService: StompService){}

    ngOninit(): void {
        this.stompService.configure({
            host: "***mystompurl***"
        });

        this.stompService.startConnect()
            .then(() => {
                console.log('Stomp connected');
                this.subscription = this.stompService.subscribe('/topic/mytopic', (msg, headers) => {
                    // Message handler code
                }); 
            });
    }

    ngOnDestroy(): void {
        if (this.subscription) {
            console.log('Unsubscribing');
            this.stompService.unsubscribe(this.subscription);
            this.subscription = null;
        }
       this.stompService.disconnect().then(() => console.log('Stomp disconnected');
    }
}

The first time the component is initialised everything works fine and messages can be sent and received. When the user leaves the page and the component is destroyed I can see the 'Unsubscribing' and 'Stomp disconnected' console entries.

The second time the user goes into the page and the component is initialised again, I get the 'Stomp connected' console entry, but then I immediately receive the following stack trace.

Error: InvalidStateError: The connection has not been established yet
    at ZoneAwareError (http://localhost:4200/polyfills.bundle.js:6988:33)
    at SockJS.send (http://localhost:4200/vendor.bundle.js:119988:11)
    at Client._transmit (http://localhost:4200/vendor.bundle.js:70078:26)
    at Client.subscribe (http://localhost:4200/vendor.bundle.js:70298:12)
    at StompService.subscribe (http://localhost:4200/vendor.bundle.js:100552:27)
    at http://localhost:4200/main.bundle.js:877:53
    at ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:6330:26)
    at Object.onInvoke (http://localhost:4200/vendor.bundle.js:4753:37)
    at ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:6329:32)
    at Zone.run (http://localhost:4200/polyfills.bundle.js:6122:43)
    at http://localhost:4200/polyfills.bundle.js:6709:57
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:6363:31)
    at Object.onInvokeTask (http://localhost:4200/vendor.bundle.js:4744:37)
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:6362:36)
    at Zone.runTask (http://localhost:4200/polyfills.bundle.js:6162:47)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.