tornadio icon indicating copy to clipboard operation
tornadio copied to clipboard

HTTPError: HTTP 401: Unauthorized (Invalid session)

Open statico opened this issue 13 years ago • 5 comments

polling.py, line 66, raises this error if the XHR long-polling session expires.

Can you elaborate on this a bit more? How does this occur and why is the default 30 seconds? This seems to cause strange behavior on the client-side — how can my clients handle this gracefully?

Thanks :)

statico avatar Apr 27 '11 07:04 statico

(Also, I'd like to add, other than this, TornadIO has been working flawlessly. Great job.)

statico avatar Apr 27 '11 07:04 statico

Hi,

There are two possible scenarios:

  1. It took longer than 15 seconds for client to reconnect after previous request.
  2. Browser closed connection, which is considered as a erroneous condition by socket.io
  3. Happens if your server declined connection (closed it, but client decided to reconnect).

Here's "normal" XHR long-polling working sequence:

  1. Client makes request
  2. Server accepts request and keeps it for 20 seconds (by default) open
  3. If there's no data to be sent to the client, server sends empty packet and closes connection
  4. Client sees that something was received and reconnects with same session id.

So, if you changed long-polling timeout to 30 seconds, there's chance that browser will kill running connection, which will raise exception in socket.io, which will prevent socket.io to reconnect automatically.

Serge.

On 27.04.2011 10:27, statico wrote:

polling.py, line 66, raises this error if the XHR long-polling session expires.

Can you elaborate on this a bit more? How does this occur and why is the default 30 seconds? This seems to cause strange behavior on the client-side — how can my clients handle this gracefully?

Thanks :)

mrjoes avatar Apr 27 '11 09:04 mrjoes

Just in case, I can prevent it from throwing exception - some debugging message might work better. Newer versions of socket.io (6.x branch) now understand that server does not want them with their session id and will attempt to reconnect to get new session id.

mrjoes avatar Apr 28 '11 21:04 mrjoes

What would be the proper way to "hide" that exception? All the stack traces make the terminal output quite unreadable when restarting the server.

tcatm avatar Jul 31 '11 13:07 tcatm

Hi,

You can stop request here: https://github.com/MrJoes/tornadio/blob/master/tornadio/polling.py#L64

Right now it will send back proper response (http code 401, but it will be also logged).

Serge.

On Sun, Jul 31, 2011 at 4:30 PM, tcatm [email protected] wrote:

What would be the proper way to "hide" that exception? All the stack traces make the terminal output quite unreadable when restarting the server.

Reply to this email directly or view it on GitHub: https://github.com/MrJoes/tornadio/issues/13#issuecomment-1695048

mrjoes avatar Jul 31 '11 15:07 mrjoes