websocket catch data when reconnecting process?

2272 views javascript

websocket connection will auto close after a few minutes if server doesnot push data to client. I watch the close event, and reconnect websocket.

But reconnecting websocket will spend a few seconds. At the reconnecting time, if server send data, client will lose these data.

How should I do if I want to catch data when reconnecting websocket ?

answered question

1 Answer


You can cache your data in server if websocket connection is in closed state. As soon as connection established push data to client.

For caching there are multiple options Redis - https://redis.io/ or memcached - https://memcached.org/

posted this

Have an answer?


Please login first before posting an answer.