Mouna Ben Ayed
Mouna Ben Ayed

Reputation: 53

Invalid session / Session is disconnected

What can be the reasons that cause a socket.io session to be crashed and server returns invalid session or session is disconnected ?

Upvotes: 3

Views: 3506

Answers (2)

Mouna Ben Ayed
Mouna Ben Ayed

Reputation: 53

Ok, I'll illustrate my problem in this figure project's architecture . In fact, I have a websocket between the react app and the rasa ( tool for creating chatbots) based on flask. bot response need to access to an external API to retrieve some data. Here where things go wrong. Sometimes, these requests take too long to return a response, and that's when websocket misbehave.

Upvotes: 1

Miguel Grinberg
Miguel Grinberg

Reputation: 67509

There is a specific situation that causes these problems with the session. When a client fails to send the pings at the expected interval the server declares the client gone and deletes the session. If a client that falls into this situation later tries to send a ping or another request using the now invalidated session id it will receive one of these errors.

Another possible problem with the same outcome is when the client does send the pings at the correct intervals, but the server is blocked or too busy to process these pings in time.

So to summarize, if you think your clients are well behaved, I would look at potential blocking tasks in your server.

Upvotes: 2

Related Questions