Websocket auto reconnect

yoursvsr
Hi Team,

Could you please explain why the .net client websocket reconnect code here is designed in such a way that it aborts the connection and attempts to reconnect every time the timer interval count goes below 0 ?

Why can't it simply check the connection state and attempt reconnect only if not already in connected state? Is this intended, and if yes, why?

Thanks.
  • sujith
    There are scenarios where Websocket isConnected will still give you true, even though user is not connected.
    Since websocket message handling is not like HTTP where you get to know if there is a data loss. A user might never know if data is lost.

    To reproduce the scenario, you may connect your laptop with a LAN cable and start websocket connection, pull the cable out. Websocket isConnected will still give you true.
  • yoursvsr
    Ok @sujith, now I begin to understand. Thanks.
This discussion has been closed.