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

WebSocketProtocol13.periodic_ping exception #2136

Open
tsantor opened this issue Aug 18, 2017 · 4 comments
Open

WebSocketProtocol13.periodic_ping exception #2136

tsantor opened this issue Aug 18, 2017 · 4 comments

Comments

@tsantor
Copy link

tsantor commented Aug 18, 2017

We are running a Tornado TCP server on a Windows server 2012 machine. This machine handles both an HTTP-based dashboard and 21 TCP Websocket connected clients. Occasionally in the logs we will see the following error. It seems to be at a very low level of the Websocket13 protocol. But from a networking standpoint what does it mean? Why would the write buffer not be greater than or equal to 0?

[ERROR] [2017-08-17 11:54:14 AM] [tornado.application] Exception in callback <bound method WebSocketProtocol13.periodic_ping of <tornado.websocket.WebSocketProtocol13 object at 0x01D7AD30>>

Traceback (most recent call last):

File "C:\Python27\lib\site-packages\tornado\ioloop.py", line 1026, in _run

    return self.callback()

File "C:\Python27\lib\site-packages\tornado\websocket.py", line 1030, in periodic_ping

    self.write_ping(b'')

File "C:\Python27\lib\site-packages\tornado\websocket.py", line 790, in write_ping

    self._write_frame(True, 0x9, data)

File "C:\Python27\lib\site-packages\tornado\websocket.py", line 768, in _write_frame

    return self.stream.write(frame)

File "C:\Python27\lib\site-packages\tornado\iostream.py", line 406, in write

    self._handle_write()

File "C:\Python27\lib\site-packages\tornado\iostream.py", line 847, in _handle_write

    assert self._write_buffer_size >= 0

AssertionError
@bdarnell
Copy link
Member

I don't know what could be causing this; I haven't seen this assertion fire before. It could be a threading problem (Are you using multiple threads?), or it could be a windows-specific issue (can you reproduce this on linux?). Windows is not a fully-supported platform for Tornado so I'm afraid I won't be much help debugging if it turns out to be windows-specific.

@tsantor
Copy link
Author

tsantor commented Aug 28, 2017

Thanks for the response. I have never seen this issue occur when running under a Linux or a Unix (OS X) environment and it has run for countless hours under both without issue.

When you say that "Windows is not a fully-supported platform" can you enlighten me as to what specifically is not supported or is not stable when running under Windows? We've used Tornado successfully for TCP socket servers in the past on Windows without issue.

Also, are there any plans to officially support Windows?

@bdarnell
Copy link
Member

"Not fully supported" means a couple of things. The big one is what you're seeing here: I don't run windows (nor does anyone else actively involved in tornado development as far as I know) and can't be much help with debugging. Windows users need to be more self-sufficient and debug their own problems. Second, Tornado on windows uses a POSIX-emulation layer that is less scalable and efficient than what we use on native posix platforms. Tornado on windows can only handle a few hundred connections per process (versus thousands or tens of thousands on linux) and it's much slower (the tornado test suite runs in 15 seconds on linux and several minutes on windows).

The first could be addressed by a volunteer who has (or could develop) the necessary expertise with windows networking. The second point is unlikely to change in Tornado; the POSIX-centric assumptions in the event loop design run deep (maybe after Tornado has dropped support for python 2 we could move towards using asyncio's windows-friendly interfaces). If windows is important for you, I would encourage you to look at using asyncio instead of tornado (note that while tornado can run on top of asyncio, doing so on windows requires running asyncio in a mode that doesn't address the performance or scalability issues here).

@tsantor
Copy link
Author

tsantor commented Aug 28, 2017

Thanks for the explanation. Windows is not usually our preferred deployment platform. We'd always prefer Linux. However, we were asked to put the server on Windows since the client can support the platform with their existing IT (Windows guys). We were not aware of any issues as we've run small scale Tornado servers in the past successfully. We also discovered first hand that a Tornado application will crash with anything over 510 TCP clients on Windows.

Looks like we're on our own in Windows land, but thanks for your time. We'll most likely recommend a move back to Linux and be done with it.

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

No branches or pull requests

2 participants