Closed Alexandr-fly-code closed 4 years ago
Need some more information:
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);
});`
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
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?
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.
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!
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?