gevent-socketio
gevent-socketio copied to clipboard
WebSocketError: Received an invalid frame_type=255
If I kill a client that uses websockets abruptly, I receive the following:
Traceback (most recent call last): File "/usr/lib64/python2.7/site-packages/gevent/greenlet.py", line 390, in run result = self._run(_self.args, *_self.kwargs) File "/usr/lib/python2.7/site-packages/gevent_socketio-0.3.5_rc3-py2.7.egg/socketio/transports.py", line 247, in read_from_ws message = websocket.receive() File "/usr/lib/python2.7/site-packages/geventwebsocket/websocket.py", line 93, in receive raise WebSocketError("Received an invalid frame_type=%r" % frame_type) WebSocketError: Received an invalid frame_type=255 <Greenlet at 0x14b74b0: read_from_ws> failed with WebSocketError
I wrapped the 'message = websocket.receive()' in a try/catch and now I get the proper 'disconnect' that I was seeking: try: message = websocket.receive() except: socket.disconnect() break
My question is is this the correct way to go about it?
Thanks much.
This shouldn't be an issue anymore. Can you test with latest master?
@Irooniam Let me know if you still have this problem in master, we are going to be making a release soon but want to make sure this is fixed.
@sontek I'll test this first thing Monday and let you know. Thanks for coming up with the (potential) fix.
That didn't seem to fix it.
I uninstalled the previous version, git-cloned master and reinstalled gevent-socketio.
Traceback (most recent call last): File "/usr/lib64/python2.7/site-packages/gevent/greenlet.py", line 390, in run result = self._run(_self.args, *_self.kwargs) File "/usr/lib/python2.7/site-packages/gevent_socketio-0.3.6-py2.7.egg/socketio/transports.py", line 259, in read_from_ws message = websocket.receive() File "/usr/lib/python2.7/site-packages/geventwebsocket/websocket.py", line 93, in receive raise WebSocketError("Received an invalid frame_type=%r" % frame_type) WebSocketError: Received an invalid frame_type=255 <Greenlet at 0x20865f0: read_from_ws> failed with WebSocketError
Can you provide an example of what you are doing so we can reproduce this?
Also, you aren't working out of a virtualenv? You are installing it directly to your system site packages?
Absolutely.
In the sio server I have a disconnect handler which just prints the socket id.
Install pywebkitgtk
You should then have a demo py script to run the webkit, mine was located at: /usr/share/doc/pywebkitgtk-1.1.8/demos/browser.py
Now run the webkit via python: python /usr/share/doc/pywebkitgtk-1.1.8/demos/browser.py
Point the browser to your socketio server and have it serve up some basic code to connect to sio server.
The sio server output looks something likes this for me: 192.168.56.101 - - [2012-11-26 09:09:37] "GET /chat.html HTTP/1.1" 200 2830 0.000383 192.168.56.101 - - [2012-11-26 09:09:37] "GET /static/css/style.css HTTP/1.1" 200 4361 0.000463 192.168.56.101 - - [2012-11-26 09:09:37] "GET /static/socket.io.js HTTP/1.1" 200 100089 0.000500 192.168.56.101 - - [2012-11-26 09:09:37] "GET /static/jquery-1.6.1.min.js HTTP/1.1" 200 91452 0.003981 192.168.56.101 - - [2012-11-26 09:09:38] "GET /favicon.ico HTTP/1.1" 404 101 0.000146 192.168.56.101 - - [2012-11-26 09:09:52] "GET /socket.io/1/websocket/777648195653 HTTP/1.1" 101 - - connect {u'name': u'abc', u'user': u'123'} with session 777648195653
Now just close the webkit or even just reload the page and you should see the error: Traceback (most recent call last): File "/usr/lib64/python2.7/site-packages/gevent/greenlet.py", line 390, in run result = self._run(_self.args, *_self.kwargs) File "/usr/lib/python2.7/site-packages/gevent_socketio-0.3.6-py2.7.egg/socketio/transports.py", line 259, in read_from_ws message = websocket.receive() File "/usr/lib/python2.7/site-packages/geventwebsocket/websocket.py", line 93, in receive raise WebSocketError("Received an invalid frame_type=%r" % frame_type) WebSocketError: Received an invalid frame_type=255 <Greenlet at 0x12640f0: read_from_ws> failed with WebSocketError
Yeah, looks like yoiu are still running the pypi version of gevent_socketio, I don't have this issue running master. I opened 2 python webkit browsers and a chrome browser to it and had them chat and disconnect and it all worked.
But by looking at your paths: /usr/lib/python2.7/site-packages/gevent_socketio-0.3.6-py2.7.egg/
seems like its installed into system libs instead of in your virtualenv.
I installed virtualenv and I still get the error.
[guest@lamp src]$ ~/testenv/bin/pip-2.7 uninstall gevent-socketio Uninstalling gevent-socketio: /home/guest/testenv/lib/python2.7/site-packages/gevent_socketio-0.3.5_rc2-py2.7.egg-info /home/guest/testenv/lib/python2.7/site-packages/socketio Proceed (y/n)? y Successfully uninstalled gevent-socketio [guest@lamp src]$ cd [guest@lamp ~]$ git clone https://github.com/abourget/gevent-socketio.git Cloning into 'gevent-socketio'... remote: Counting objects: 2428, done. remote: Compressing objects: 100% (1023/1023), done. remote: Total 2428 (delta 1507), reused 2281 (delta 1372) Receiving objects: 100% (2428/2428), 1.31 MiB | 948 KiB/s, done. Resolving deltas: 100% (1507/1507), done. [guest@lamp ~]$ cd gevent-socketio/ [guest@lamp gevent-socketio]$ ~/testenv/bin/python setup.py install
Installed /home/guest/gevent-socketio/versiontools-1.9.1-py2.7.egg running install running bdist_egg running egg_info creating gevent_socketio.egg-info writing requirements to gevent_socketio.egg-info/requires.txt writing gevent_socketio.egg-info/PKG-INFO writing top-level names to gevent_socketio.egg-info/top_level.txt writing dependency_links to gevent_socketio.egg-info/dependency_links.txt writing entry points to gevent_socketio.egg-info/entry_points.txt writing manifest file 'gevent_socketio.egg-info/SOURCES.txt' reading manifest file 'gevent_socketio.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no previously-included files found matching 'socketio/.ropeproject/*' warning: no previously-included files found matching 'socketio/sample_protocol_for_doc.py' writing manifest file 'gevent_socketio.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py creating build creating build/lib creating build/lib/socketio copying socketio/namespace.py -> build/lib/socketio copying socketio/defaultjson.py -> build/lib/socketio copying socketio/packet.py -> build/lib/socketio copying socketio/sgunicorn.py -> build/lib/socketio copying socketio/policyserver.py -> build/lib/socketio copying socketio/transports.py -> build/lib/socketio copying socketio/sdjango.py -> build/lib/socketio copying socketio/server.py -> build/lib/socketio copying socketio/handler.py -> build/lib/socketio copying socketio/mixins.py -> build/lib/socketio copying socketio/virtsocket.py -> build/lib/socketio copying socketio/init.py -> build/lib/socketio creating build/bdist.linux-x86_64 creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/namespace.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/defaultjson.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/packet.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/sgunicorn.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/policyserver.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/transports.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/sdjango.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/server.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/handler.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/mixins.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/virtsocket.py -> build/bdist.linux-x86_64/egg/socketio copying build/lib/socketio/init.py -> build/bdist.linux-x86_64/egg/socketio byte-compiling build/bdist.linux-x86_64/egg/socketio/namespace.py to namespace.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/defaultjson.py to defaultjson.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/packet.py to packet.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/sgunicorn.py to sgunicorn.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/policyserver.py to policyserver.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/transports.py to transports.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/sdjango.py to sdjango.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/server.py to server.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/handler.py to handler.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/mixins.py to mixins.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/virtsocket.py to virtsocket.pyc byte-compiling build/bdist.linux-x86_64/egg/socketio/init.py to init.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying gevent_socketio.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying gevent_socketio.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying gevent_socketio.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying gevent_socketio.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying gevent_socketio.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying gevent_socketio.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... creating dist creating 'dist/gevent_socketio-0.3.6-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing gevent_socketio-0.3.6-py2.7.egg Copying gevent_socketio-0.3.6-py2.7.egg to /home/guest/testenv/lib/python2.7/site-packages Adding gevent-socketio 0.3.6 to easy-install.pth file
Installed /home/guest/testenv/lib/python2.7/site-packages/gevent_socketio-0.3.6-py2.7.egg Processing dependencies for gevent-socketio==0.3.6 Searching for gevent-websocket==0.3.6 Best match: gevent-websocket 0.3.6 Adding gevent-websocket 0.3.6 to easy-install.pth file
Using /home/guest/testenv/lib/python2.7/site-packages Searching for greenlet==0.4.0 Best match: greenlet 0.4.0 Adding greenlet 0.4.0 to easy-install.pth file
Using /home/guest/testenv/lib/python2.7/site-packages Searching for gevent==0.13.8 Best match: gevent 0.13.8 Adding gevent 0.13.8 to easy-install.pth file
Using /home/guest/testenv/lib/python2.7/site-packages Finished processing dependencies for gevent-socketio==0.3.6 [guest@lamp gevent-socketio]$ cd /var/www/source/systems/chat/sb/guest/src [guest@lamp src]$ ~/testenv/bin/python chat.py 9000 A Listening on port 8080 and on port 843 (flash policy server) 192.168.56.101 - - [2012-11-27 12:40:01] "GET /chat.html HTTP/1.1" 200 2780 0.000347 192.168.56.101 - - [2012-11-27 12:40:01] "GET /static/css/style.css HTTP/1.1" 200 4361 0.000622 192.168.56.101 - - [2012-11-27 12:40:01] "GET /static/socket.io.js HTTP/1.1" 200 100089 0.001073 192.168.56.101 - - [2012-11-27 12:40:01] "GET /static/jquery-1.6.1.min.js HTTP/1.1" 200 91452 0.002414 192.168.56.101 - - [2012-11-27 12:40:01] "GET /favicon.ico HTTP/1.1" 404 101 0.000085 192.168.56.101 - - [2012-11-27 12:40:07] "GET /socket.io/1/websocket/926238808793 HTTP/1.1" 101 - - connect {u'name': u'test', u'user': u'123'} with session 926238808793 Traceback (most recent call last): File "/home/guest/testenv/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run result = self._run(_self.args, *_self.kwargs) File "build/bdist.linux-x86_64/egg/socketio/transports.py", line 259, in read_from_ws message = websocket.receive() File "/home/guest/testenv/lib/python2.7/site-packages/geventwebsocket/websocket.py", line 93, in receive raise WebSocketError("Received an invalid frame_type=%r" % frame_type) WebSocketError: Received an invalid frame_type=255 <Greenlet at 0x25a2410: read_from_ws> failed with WebSocketError
@Irooniam Do you still have this issue?