On Wed, Jan 9, 2013 at 1:23 PM, Kamil Krzyszczuk
<
krzyszc...@gmail.com> wrote:
> How often I will get reconnect notice in SockJS? I know there isn't a native
> reconnect mechanism, but I built one this way:
> if onclose, then sockjs = new connection;
Beware with that. You can easily DDOS your server when you'll have
a network hiccup or if you'll restart your server.
Better way is to introduce a timer and an exponential backoff mechanism.
(on the client side)
> but then I lost session_id because it gets new one. So I wonder how often
> reconnect happen in big applications. Because if it happens often in SockJS
> then I will have to switch back to Socket.io because even if
socket.io
> reconnect, session_id isn't lost.
>
> Maybe someone who handle big traffic can reply this topic?
Lack of built-in reconnection mechanism and not reusing session_id is
deliberate.
You need to build the reconnection and re-synchronization mechanisms
in your application. This is your responsibility.
SockJS gives you a tcp/ip like layer - a connection. If a connection is
broken, for any reason, it's the application that needs to understand that
and react accordingly.
If you have some state connected to the session (username,
last-delivered-message number, etc) - you need to pass that
information to the new session. But all that stuff is very application
specific and SockJS can't help you with it.
Marek