I keep getting the below error on the initial handshake it looks like. Have you seen this before and is my setup wrong? Python 2.7 and eventlet
[2016-01-27 12:41:50 -0800] [62647] [ERROR] Error handling request
Traceback (most recent call last):
File "/Users/brianclark/Desktop/Projects/HDP/application/api/venv/lib/python2.7/site-packages/gunicorn/workers/async.py", line 52, in handle
self.handle_request(listener_name, req, client, addr)
File "/Users/brianclark/Desktop/Projects/HDP/application/api/venv/lib/python2.7/site-packages/gunicorn/workers/async.py", line 114, in handle_request
resp.close()
File "/Users/brianclark/Desktop/Projects/HDP/application/api/venv/lib/python2.7/site-packages/gunicorn/http/wsgi.py", line 423, in close
self.send_headers()
File "/Users/brianclark/Desktop/Projects/HDP/application/api/venv/lib/python2.7/site-packages/gunicorn/http/wsgi.py", line 316, in send_headers
tosend = self.default_headers()
File "/Users/brianclark/Desktop/Projects/HDP/application/api/venv/lib/python2.7/site-packages/gunicorn/http/wsgi.py", line 297, in default_headers
elif self.should_close():
File "/Users/brianclark/Desktop/Projects/HDP/application/api/venv/lib/python2.7/site-packages/gunicorn/http/wsgi.py", line 230, in should_close
if self.status_code < 200 or self.status_code in (204, 304):
AttributeError: 'Response' object has no attribute 'status_code'
Here's my pip freeze
aniso8601==1.1.0
blinker==1.4
boto3==1.2.1
botocore==1.3.3
bson==0.4.1
docutils==0.12
eventlet==0.18.1
Flask==0.10.1
Flask-Cors==2.1.2
Flask-HTTPAuth==2.7.0
Flask-Mail==0.9.1
Flask-RESTful==0.3.4
Flask-SocketIO==2.0
Flask-SQLAlchemy==2.1
futures==2.2.0
greenlet==0.4.9
gunicorn==19.3.0
itsdangerous==0.24
Jinja2==2.8
jmespath==0.9.0
MarkupSafe==0.23
passlib==1.6.5
psycopg2==2.6.1
python-dateutil==2.4.2
python-engineio==0.8.7
python-socketio==1.0
pytz==2015.7
requests==2.9.1
six==1.10.0
SQLAlchemy==1.0.11
Werkzeug==0.10.4
wheel==0.24.0
Ah so it looks like one of my calls had an error in it but it seems the bug got picked up at this point in the chain of things, can close this but know if you see this error it's likely your code has a bug in it and is crashing the socket!
@bclark8923 You should use try gunicorn version 18.0
Gunicorn release 18.0 is the recommended release to use with Flask-SocketIO. The 19.x releases are known to have incompatibilities in certain deployment scenarios that include WebSocket.
But I am also having the same issue when running version 18, but could notice some hiccups for that matter but apart from this it is working super fast!
Plus, when running with the dev server, the only thing that works are the "server generated" msgs. Meanwhile I am using the --reload flag from gunicorn to work.
@cescoferraro I ended up having a bug in my code where something was undefined and then socket.io just crashed. When I fixed that error it all started operating fine
I also have this problem where the client is intermittently disconnected and connected.
I am running this with gunicorn behind an nginx. I followed the configuration from the docs.
I can receive emits, but still it disconnects randomly.
In my logs I have this...
2017-05-12 03:13:07 [32004] [INFO] Starting gunicorn 18.0
2017-05-12 03:13:07 [32004] [INFO] Listening at: unix:/tmp/gunicorn.sock (32004)
2017-05-12 03:13:07 [32004] [INFO] Using worker: eventlet
2017-05-12 03:13:07 [32007] [INFO] Booting worker with pid: 32007
Server initialized for eventlet.
Server initialized for eventlet.
42bdbe78ddbd41acaf80721534beb03a: Sending packet OPEN data {'pingTimeout': 60000, 'pingInterval': 25000, 'upgrades': [], 'sid': '42bdbe78ddbd41acaf80721534beb03a'}
42bdbe78ddbd41acaf80721534beb03a: Sending packet MESSAGE data 0
42bdbe78ddbd41acaf80721534beb03a: Received request to upgrade to websocket
42bdbe78ddbd41acaf80721534beb03a: Upgrade to websocket successful
42bdbe78ddbd41acaf80721534beb03a: Received packet MESSAGE data 0/notification
42bdbe78ddbd41acaf80721534beb03a: Sending packet MESSAGE data 0/notification
42bdbe78ddbd41acaf80721534beb03a: Sending packet MESSAGE data 2/notification,["joined","test123"]
42bdbe78ddbd41acaf80721534beb03a: Unexpected error "timed out", closing connection
2017-05-12 03:13:41 [32007] [ERROR] Error handling request
Traceback (most recent call last):
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/workers/async.py", line 45, in handle
self.handle_request(listener, req, client, addr)
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/workers/async.py", line 102, in handle_request
resp.close()
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 369, in close
self.send_headers()
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 284, in send_headers
tosend = self.default_headers()
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 265, in default_headers
elif self.should_close():
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 198, in should_close
if self.status_code < 200 or self.status_code in (204, 304):
AttributeError: 'Response' object has no attribute 'status_code'
21371ee614c0413f92c302aebb2fe9f3: Sending packet OPEN data {'pingTimeout': 60000, 'pingInterval': 25000, 'upgrades': [], 'sid': '21371ee614c0413f92c302aebb2fe9f3'}
21371ee614c0413f92c302aebb2fe9f3: Sending packet MESSAGE data 0
21371ee614c0413f92c302aebb2fe9f3: Received request to upgrade to websocket
21371ee614c0413f92c302aebb2fe9f3: Upgrade to websocket successful
21371ee614c0413f92c302aebb2fe9f3: Received packet MESSAGE data 0/notification
21371ee614c0413f92c302aebb2fe9f3: Sending packet MESSAGE data 0/notification
21371ee614c0413f92c302aebb2fe9f3: Sending packet MESSAGE data 2/notification,["joined","test123"]
21371ee614c0413f92c302aebb2fe9f3: Unexpected error "timed out", closing connection
2017-05-12 03:14:12 [32007] [ERROR] Error handling request
Traceback (most recent call last):
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/workers/async.py", line 45, in handle
self.handle_request(listener, req, client, addr)
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/workers/async.py", line 102, in handle_request
resp.close()
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 369, in close
self.send_headers()
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 284, in send_headers
tosend = self.default_headers()
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 265, in default_headers
elif self.should_close():
File "/home/ec2-user/prj_backend/env/local/lib/python3.5/site-packages/gunicorn/http/wsgi.py", line 198, in should_close
if self.status_code < 200 or self.status_code in (204, 304):
AttributeError: 'Response' object has no attribute 'status_code'
I cant find any bug in my code though (for now) as it is perfectly running on my local development server (also the socketio is working perfect), which is also running via gunicorn only, not behing anything.
P.S. This is only listen, I did not emit anything to the server. Same tests I did for my local.
@richmondwang upgrade your gunicorn to the latest release. They have fixed this error already.
oh!, Because the docs said it recommends the 18.0 release.. Thanks @miguelgrinberg !
Good job with this project, i love it 馃憤
@richmondwang yeah, sorry about that. When the 19.x releases of gunicorn came out there were a lot of problems, but now in the 19.7.x things are looking a lot better. I need to remove that warning from the docs, it is now outdated.
It's totally cool.
Now I don't get the AttributeError but still disconnects randomly, but I guess it's better than getting the error, so I'm good with this. Thank!
Do you have any other stack traces at the point where a disconnect happens?
Sorry for the late reply.
I was able to debug and output the logs from the server but when the disconnect happens, I see nothing else besides when the client re-connects again. I think the issue might be with the client. I need to investigate further.
**### Hi everyone, I am getting "Server Request Interrupted" error when I am trying to make request to IBM Watson Speech to text service. I am using SocketIO withy Gunicorn v 18.0. Everything was working perfectly before introducing SocketIO.
requirements.txt file:
**asn1crypto==0.24.0
attrs==18.1.0
autobahn==18.6.1
Automat==0.7.0
bcrypt==3.1.4
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
click==6.7
constantly==15.1.0
cryptography==2.2.2
dominate==2.3.1
enum34==1.1.6
Flask==1.0.2
Flask-Bcrypt==0.7.1
Flask-Bootstrap==3.3.7.1
Flask-Login==0.4.1
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
gunicorn==18.0
hyperlink==18.0.0
idna==2.7
incremental==17.5.0
ipaddress==1.0.22
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
oocsi==0.4
Pillow==5.1.0
psycopg2==2.7.5
pyasn1==0.4.3
pyasn1-modules==0.2.2
pycparser==2.18
pyOpenSSL==18.0.0
python-dateutil==2.7.3
requests==2.19.1
scipy==1.0.0
service-identity==17.0.0
six==1.11.0
SQLAlchemy==1.2.10
Twisted==18.4.0
txaio==2.10.0
Unidecode==1.0.22
urllib3==1.23
virtualenv==16.0.0
visitor==0.1.3
Werkzeug==0.14.1
ws4py==0.5.1
WTForms==2.2.1
zope.interface==4.5.0
watson-developer-cloud==1.4.1
boto==2.49.0
Flask-SocketIO==3.0.2
gevent==1.3.6
eventlet==0.24.1
Flask-Script==2.0.6
Flask-Migrate==2.3.0
Procfile is:
web: gunicorn -k eventlet run:flask_app
Error is:
2018-11-19T17:02:43.466528+00:00 heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=GET path="/static/js/watson-speech.js" host=[HOST WAS REMOVED] request_id=b59b2f39-4e18-4f02-a6df-a601147396e3 fwd="131.155.162.87" dyno=web.1 connect=3ms service=22ms status=503 bytes= protocol=https**
@richmondwang Heroku has a support page with information on how to troubleshoot H18 errors: https://help.heroku.com/18NDWDW0/debugging-h18-server-request-interrupted-errors-in-nodejs-applications. At this point I don't see how Socket.IO can be related, but maybe eventlet is.
@miguelgrinberg Thank you for that.
Unfortunately, I cant help any further with this issue as I have inherited the project already to other developers.