Closed ohardy closed 6 years ago
You mean when connecting to /websocket
directly?
That's expected behaviour: https://github.com/sockjs/sockjs-node#connecting-to-sockjs-node-without-the-client
Nope, with sockjs-client
Hm, then I don't know.
The server should send this h
frame every 25seconds I think.
Any debug that I can enable to see why ?
I think this is related to: https://github.com/sockjs/sockjs-node/blob/14a5c3cf097126bde74436d001816c53a0593d43/src/trans-websocket.coffee#L95-L101
If ws.ping
method returns true (client is compatible), SockJS doesn't send an h
frame and use protocol mechanism. No frame will be shown in devtools but it works: handler is called on pong and the timeout is cleared. No problem with this on the server side.
But the socket.onheartbeat()
event/handler is not called on the client side if ws.ping
is used. It is called only if I modify the code to force h
frame use.
I would be really happy to make a PR if you lead me down the right path to fix this. I really don't want to switch to engine.io
because of this.
cc @majek @brycekahle
@chabou What do you need to do on heartbeats? They are a half-baked feature (as you can tell) and really shouldn't be exposed to the user.
@brycekahle This error happens a lot on mobile: https://github.com/sockjs/sockjs-client/issues/64
I found that relying on onkeepalive
event was perfect to ensure a healthy connection on the client side.
I believe the original question has been answered, so I'm going to close this issue.
Anything to see why ?