-
Notifications
You must be signed in to change notification settings - Fork 59
webstomp.over() not working from a callback #5
Comments
I don't know what are your trying to achieve here. Why are you not just doing var ws = new SockJS(GLOBAL.apiUrl.replace('/v3', '') + '/notifications');
var client = webstomp.over(ws);
client.connect(...); Look at the SockJS broadcast example. |
The problem is that the SockJS connection is not instant and sometimes it takes some time. If that happens and stomp tries to connect over that SockJS connection while it is still connecting, SockJS throws the following error: |
Ok that is the real issue to solve then. Even though using webstomp.over
|
The example you posted works, but SockJS throws the error sometimes. When I try to establish stomp connection from within a function, it does not work at all. Either or, there is a bug somewhere. It would probably help to do some sort of check to make sure |
Back to your 1st example, you cannot use But, you can use So I'm sorry but I have no other solution than #5 (comment) |
I have just noticed something else. The callback itself does not seem to be the problem. It seems the stomp connection is not established if there is delay between creating the SockJS connection and the stomp connection. The example below hangs on "Opening Web Socket...". var ws = new SockJS(GLOBAL.apiUrl.replace('/v3', '') + '/notifications');
var client = Stomp.over(ws);
function connect() {
if (ws.readyState !== SockJS.OPEN) {
setTimeout(connect, 100);
return;
}
client.connect({}, function () { ... });
} In my opinion the stomp should be able to use SockJS connection at any time. Do you have any idea what could cause the stomp client not wanting to connect after a delay? |
I probably know why. The connection is being established after Closing this as it seems like it is an issue on SockJS side after all if it executes |
As I said, |
There is a problem when establishing connection over SockJS from a callback function. The original stomp client had the same issue.
The following code works
but if I replace
webstomp.client(...);
withwebstomp.over(ws);
, the client is stuck on "Opening Web Socket..." message.Also this is not a scoping issue, because I can
console.log
thews
variable from within the callback. I have tried switchingws
forthis
in the callback (asthis
in the context points tows
), but that does not work either.The text was updated successfully, but these errors were encountered: