Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Multiple connection #218

Closed
kelvinsleonardo opened this issue Feb 1, 2021 · 5 comments
Closed

Multiple connection #218

kelvinsleonardo opened this issue Feb 1, 2021 · 5 comments

Comments

@kelvinsleonardo
Copy link

kelvinsleonardo commented Feb 1, 2021

I'm using the follow configuration manual: #121 (comment)
Angular: 9.0.7
@stomp/ng2-stompjs: 8.0.0

I am simulating loss of connection with the server. When the library tries to reconnect, some requests / sessions are made successfully. Instead of just one. Check images below

All status 101 is successful

detail

First connection successful

detail2

Second connection successful

detail3

@kum-deepak
Copy link
Member

The v8 has some additional logic, which may cause this behavior. Please share your configuration and debug output.

@kelvinsleonardo
Copy link
Author

Config

  export const websocketStompConfig:InjectableRxStompConfig = {
 
    brokerURL: 'ws://url-server/socket',

    connectHeaders: {
      Authorization: 'guest',
      passcode: 'guest',
    },

    heartbeatIncoming: 0, 

    heartbeatOutgoing: 20000,

    reconnectDelay: 2000,
  
    debug: (msg: string): void => {
      console.log(new Date(), msg);
    }
};`

Init

 private initStomp() {
      const stompConfig: InjectableRxStompConfig = Object.assign({}, websocketStompConfig, {
          connectHeaders: {
              Authorization: this.webStorage.userAuthorization
          },
          brokerURL: `${Constant.WEBSOCKET}?Authorization=${this.webStorage.userAuthorization}`,
          beforeConnect: () => {
              // console.log('%c called before connect', 'color: blue');
          }
      });

      this.rxStompService.configure(stompConfig);
      this.rxStompService.activate();
  }

App module

providers: [RxStompService]

1
2
3

@kum-deepak
Copy link
Member

Thanks for the detailed diagnostic report. One new feature was intorduced in v8 of this library - https://stomp-js.github.io/guide/stompjs/rx-stomp/upgrading-to-stompjs-6-rx-stomp-1.html#connectiontimeout (https://stomp-js.github.io/api-docs/latest/classes/Client.html#connectionTimeout). It seems it does not work as intended in every case.

Set it to 0 to disable this feature. Let me know if it resolves the issue.

@kelvinsleonardo
Copy link
Author

It worked. Thank's

@kum-deepak
Copy link
Member

Released @stomp/[email protected] and @stomp/[email protected]. It sets https://stomp-js.github.io/api-docs/latest/classes/Client.html#connectionTimeout to 0 to de-activate this feature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants