stomp-js / stompjs

Javascript and Typescript Stomp client for Web browsers and node.js apps
Apache License 2.0
773 stars 82 forks source link

Problem with conned to server #294

Closed Alexandr-fly-code closed 4 years ago

Alexandr-fly-code commented 4 years ago
Screen Shot 2020-10-21 at 14 48 57

Once I connect to the server, when I can't connect, it just displays "Web Socket Opened ..." and >>> CONNECT accept-version: 1.1,1.0 heart-beat: 10000,10000 - is there a problem in the server?

kum-deepak commented 4 years ago

Need some more information:

Alexandr-fly-code commented 4 years ago

Need some more information:

  • which version of the library are you using? - 2.3.3
  • which broker, including version? - you mean broker on backend?
  • are you using SockJS? - yes
  • if possible, parameters you are passing to the library? - When connect, only accept-version: 1.1,1.0 is transmitted, heart-beat: 10000,10000 - they are default.

code const action = new SockJS(https://test/${developmentMode}/cht/socket`); const stompClient = Stomp.over(action);

stompClient.connect({}, function (frame) {
  onSendOrReceiveMessage(action, stompClient, '/topic/send');
  setIsSocketClose(false);
});`
kum-deepak commented 4 years ago

You are on an old version (released more than 6 years ago). Currently, only version 5 is actively supported. v5 was rewritten grounds up.

I am unable to advise much for your current version. I can suggest to you the following:

There is an upgrade guide at https://stomp-js.github.io/guide/stompjs/upgrading-stompjs.html and an article for using with SockJS https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/using-stomp-with-sockjs.html

Alexandr-fly-code commented 4 years ago

You are on an old version (released more than 6 years ago). Currently, only version 5 is actively supported. v5 was rewritten grounds up.

I am unable to advise much for your current version. I can suggest to you the following:

  • If possible, upgrade to the latest version of this library.
  • Move away from SockJS - it is no longer needed, the issue that you are facing might be related to SockJS.

There is an upgrade guide at https://stomp-js.github.io/guide/stompjs/upgrading-stompjs.html and an article for using with SockJS https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/using-stomp-with-sockjs.html

Okay, thanks, but what to use instead of SockJS?

kum-deepak commented 4 years ago

In the early days of HTML5, SockJS was used to give Websocket like object for browsers that natively did not support Websockets natively. All the browsers have been supporting Websockets natively for many years now. Brokers always supported communication over Webscokets natively.

The actual instructions will vary based on the broker you are using. Usually, it will be finding the Websocket endpoint (which is not the same as SockJS end point) for your broker and using that with the library.

Alexandr-fly-code commented 4 years ago

In the early days of HTML5, SockJS was used to give Websocket like object for browsers that natively did not support Websockets natively. All the browsers have been supporting Websockets natively for many years now. Brokers always supported communication over Webscokets natively.

The actual instructions will vary based on the broker you are using. Usually, it will be finding the Websocket endpoint (which is not the same as SockJS end point) for your broker and using that with the library.

Got it, thanks for your help!