Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPError: HTTP 401: Unauthorized (Invalid session) #13

Open
statico opened this issue Apr 27, 2011 · 5 comments
Open

HTTPError: HTTP 401: Unauthorized (Invalid session) #13

statico opened this issue Apr 27, 2011 · 5 comments

Comments

@statico
Copy link
Contributor

statico commented Apr 27, 2011

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
Copy link
Contributor Author

statico commented Apr 27, 2011

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

@mrjoes
Copy link
Owner

mrjoes commented Apr 27, 2011

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
Copy link
Owner

mrjoes commented Apr 28, 2011

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.

@tcatm
Copy link

tcatm commented Jul 31, 2011

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

@mrjoes
Copy link
Owner

mrjoes commented Jul 31, 2011

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
reply@reply.github.com
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:
#13 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants