TL;DR: Pressing F5 on the client generates a bunch of tracebacks in the server:
packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
I have a minimal client and server running on Windows 10 and Google Chrome.
var socket = io.connect({
'sync disconnect on unload': true // makes no difference if in or out
});
# Setup
flask = Flask(__name__)
sio = SocketIO(flask)
sio.run(flask)
# Hooks
@sio.on('connect')
def connect_client():
log.info('websocket client connected from "%s"' % flask.request.sid)
@sio.on('disconnect')
def disconnected_client():
log.info('websocket client disconnected from "%s"' % flask.request.sid)
Everything is normal when launching the server.
(env) C:\Users\John\Documents\GitHub\platform-client [master +1 ~5 -0 !]> python .\run.py
engineio : INFO Server initialized for eventlet.
werkzeug : INFO * Restarting with stat
engineio : INFO Server initialized for eventlet.
werkzeug : WARNING * Debugger is active!
werkzeug : INFO * Debugger pin code: 127-711-505
(4668) wsgi starting up on http://127.0.0.1:5000/
Everything is normal connecting a client:
(4668) accepted ('127.0.0.1', 62050)
(4668) accepted ('127.0.0.1', 62051)
(4668) accepted ('127.0.0.1', 62052)
(4668) accepted ('127.0.0.1', 62053)
(4668) accepted ('127.0.0.1', 62054)
(4668) accepted ('127.0.0.1', 62055)
app.dashboard.dashboard: INFO hit route
127.0.0.1 - - [09/Jan/2016 18:45:32] "GET / HTTP/1.1" 200 8970 0.017155
engineio : INFO 38161f6c34914de39690a41195734749: Sending packet OPEN with {'upgrades': ['websocket'], 'pingTimeout': 60000, 'sid': '38161f6c34914de39690a41195734749', 'pingInterval': 25000}
app.sockets : INFO websocket client connected from "38161f6c34914de39690a41195734749"
engineio : INFO 38161f6c34914de39690a41195734749: Sending packet MESSAGE with 0
127.0.0.1 - - [09/Jan/2016 18:45:32] "GET /socket.io/?EIO=3&transport=polling&t=L8djJCa HTTP/1.1" 200 381 0.013515
(4668) accepted ('127.0.0.1', 62058)
engineio : INFO 38161f6c34914de39690a41195734749: Received request to upgrade to websocket
engineio : INFO 38161f6c34914de39690a41195734749: Sending packet NOOP with None
127.0.0.1 - - [09/Jan/2016 18:45:32] "GET /socket.io/?EIO=3&transport=polling&t=L8djJDi&sid=38161f6c34914de39690a41195734749 HTTP/1.1" 200 215 0.292030
engineio : INFO 38161f6c34914de39690a41195734749: Upgrade to websocket successful
engineio : INFO 38161f6c34914de39690a41195734749: Received packet PING with None
engineio : INFO 38161f6c34914de39690a41195734749: Sending packet PONG with None
When I press F5 in the browser, I get the following errors:
app.dashboard.dashboard: INFO hit route
127.0.0.1 - - [09/Jan/2016 18:45:57] "GET / HTTP/1.1" 200 8970 0.007009
app.sockets : INFO websocket client disconnected from "38161f6c34914de39690a41195734749"
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/css/fonts.css HTTP/1.1" 304 250 0.002503
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
(4668) accepted ('127.0.0.1', 62065)
(4668) accepted ('127.0.0.1', 62066)
(4668) accepted ('127.0.0.1', 62067)
(4668) accepted ('127.0.0.1', 62068)
(4668) accepted ('127.0.0.1', 62069)
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/bower_components/jquery/dist/jquery.min.js HTTP/1.1" 304 252 0.001501
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/bower_components/font-awesome/css/font-awesome.min.css HTTP/1.1" 304 252 0.002002
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /dashboard/static/css/sidebar.css HTTP/1.1" 304 250 0.001502
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/bower_components/bootstrap/dist/css/bootstrap.min.css HTTP/1.1" 304 253 0.001501
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/bower_components/bootstrap/dist/js/bootstrap.min.js HTTP/1.1" 304 251 0.002004
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/bower_components/socket.io-client/socket.io.js HTTP/1.1" 304 252 0.002764
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
(4668) accepted ('127.0.0.1', 62070)
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
engineio : INFO c0be9cda97ab43f5b967c7c59c9e3d76: Sending packet OPEN with {'upgrades': ['websocket'], 'pingTimeout': 60000, 'sid': 'c0be9cda97ab43f5b967c7c59c9e3d76', 'pingInterval': 25000}
app.sockets : INFO websocket client connected from "c0be9cda97ab43f5b967c7c59c9e3d76"
engineio : INFO c0be9cda97ab43f5b967c7c59c9e3d76: Sending packet MESSAGE with 0
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /socket.io/?EIO=3&transport=polling&t=L8djPV- HTTP/1.1" 200 381 0.020775
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /static/img/favicon.ico HTTP/1.1" 200 1916 0.002009
(4668) accepted ('127.0.0.1', 62073)
(4668) accepted ('127.0.0.1', 62074)
engineio : INFO c0be9cda97ab43f5b967c7c59c9e3d76: Received request to upgrade to websocket
engineio : INFO c0be9cda97ab43f5b967c7c59c9e3d76: Sending packet NOOP with None
127.0.0.1 - - [09/Jan/2016 18:45:58] "GET /socket.io/?EIO=3&transport=polling&t=L8djPYI&sid=c0be9cda97ab43f5b967c7c59c9e3d76 HTTP/1.1" 200 215 0.299452
engineio : INFO c0be9cda97ab43f5b967c7c59c9e3d76: Upgrade to websocket successful
I thought this might have been related to https://github.com/miguelgrinberg/Flask-SocketIO/issues/184 but the problem persists after an upgrade to 0.8.5
When I close a browser window, the disconnect seems to be fine - but a few seconds later I get this:
app.sockets : INFO websocket client disconnected from "a446831595b346cdaf751d7c0ab667a9"
127.0.0.1 - - [09/Jan/2016 19:02:15] "GET /socket.io/?EIO=3&transport=websocket&sid=a446831595b346cdaf751d7c0ab667a9 HTTP/1.1" 200 0 318.969000
Traceback (most recent call last):
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn_n_impl
func(*args, **kwargs)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 686, in process_request
proto.__init__(sock, address, self)
File "c:\python35\Lib\socketserver.py", line 686, in __init__
self.finish()
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "C:\Users\John\Documents\GitHub\platform-client\env\lib\site-packages\eventlet\greenio\base.py", line 469, in shutdown_safe
return sock.shutdown(socket.SHUT_RDWR)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
ApiDoc==1.2
eventlet==0.17.4
Flask==0.10.1
Flask-Assets==0.11
Flask-Bower==1.2.1
Flask-SocketIO==1.2
greenlet==0.4.9
itsdangerous==0.24
Jinja2==2.8
jsmin==2.2.0
jsonschema==2.3.0
MarkupSafe==0.23
python-engineio==0.8.5
python-socketio==0.8.2
PyYAML==3.10
simplejson==3.8.1
six==1.10.0
webassets==0.11.1
Werkzeug==0.11.3
wheel==0.24.0
Any thoughts? Thanks very much!
Does everything work okay in spite of the stack traces?
These errors seem to me like the equivalent of the "broken pipe" errors you get on Posix based OSes when the client also goes away unexpectedly or abandons a connection to start another one (the refresh case).
I intend to investigate these to confirm they are bugs in eventlet and gevent. I don't believe they are issues with this extension. In any case, the errors indicate that the connection has been dropped by the other side, which is actually correct. If the errors cause any problems, such as inability of clients from making new connections, please let me know. My impression is that they are benign.
Thanks for the quick reply! I agree, it seems benign but is worth finding+fixing.
I've had the server time out serving a page a handful of times after excessive quick refreshing, but I've not been able to reproduce consistently. Let me know how best to help further.
I have similar error but without disconnect event.
It happens after some time(looks like 1 minute) after last action. I am looking is there any kind of timeout.
* Restarting with stat
* Debugger is active!
* Debugger pin code: 200-501-276
(2076) wsgi starting up on http://0.0.0.0/
(2076) accepted ('127.0.0.1', 53335)
127.0.0.1 - - [11/Jan/2016 11:20:28] "GET /socket.io/?EIO=3&transport=polling&t=
1452511228890-5 HTTP/1.1" 200 381 0.002000
127.0.0.1 - - [11/Jan/2016 11:20:28] "POST /socket.io/?EIO=3&transport=polling&t
=1452511228948-6&sid=378063b0988c43149b90aecab5dac480 HTTP/1.1" 200 214 0.001000
127.0.0.1 - - [11/Jan/2016 11:20:28] "GET /socket.io/?EIO=3&transport=polling&t=
1452511228951-7&sid=378063b0988c43149b90aecab5dac480 HTTP/1.1" 200 223 0.000000
(2076) accepted ('127.0.0.1', 53340)
127.0.0.1 - - [11/Jan/2016 11:20:29] "GET /socket.io/?EIO=3&transport=polling&t=
1452511229000-8&sid=378063b0988c43149b90aecab5dac480 HTTP/1.1" 200 215 0.238400
(2076) accepted ('127.0.0.1', 53341)
127.0.0.1 - - [11/Jan/2016 11:20:31] "GET /task2 HTTP/1.1" 200 2789 0.013000
Client disconnected 378063b0988c43149b90aecab5dac480
127.0.0.1 - - [11/Jan/2016 11:20:31] "GET /static/css/bootstrap.min.css HTTP/1.1
" 304 246 0.001000
127.0.0.1 - - [11/Jan/2016 11:20:31] "GET /static/js/jquery.min.js HTTP/1.1" 304
246 0.001000
127.0.0.1 - - [11/Jan/2016 11:20:31] "GET /static/js/bootstrap.min.js HTTP/1.1"
304 246 0.001000
127.0.0.1 - - [11/Jan/2016 11:20:31] "GET /static/js/socket.io-1.2.0.js HTTP/1.1
" 304 245 0.002000
127.0.0.1 - - [11/Jan/2016 11:20:32] "GET /static/js/jquery.min.map HTTP/1.1" 40
4 366 0.000000
127.0.0.1 - - [11/Jan/2016 11:20:32] "GET /socket.io/?EIO=3&transport=polling&t=
1452511232115-0 HTTP/1.1" 200 381 0.000000
127.0.0.1 - - [11/Jan/2016 11:20:32] "POST /socket.io/?EIO=3&transport=polling&t
=1452511232174-1&sid=dac9b09b5b984c9d8e3c6510e9a02ae1 HTTP/1.1" 200 214 0.000000
127.0.0.1 - - [11/Jan/2016 11:20:32] "GET /socket.io/?EIO=3&transport=polling&t=
1452511232179-2&sid=dac9b09b5b984c9d8e3c6510e9a02ae1 HTTP/1.1" 200 223 0.000000
(2076) accepted ('127.0.0.1', 53346)
(2076) accepted ('127.0.0.1', 53347)
(2076) accepted ('127.0.0.1', 53348)
(2076) accepted ('127.0.0.1', 53349)
127.0.0.1 - - [11/Jan/2016 11:20:32] "GET /socket.io/?EIO=3&transport=polling&t=
1452511232213-3&sid=dac9b09b5b984c9d8e3c6510e9a02ae1 HTTP/1.1" 200 215 0.247800
127.0.0.1 - - [11/Jan/2016 11:21:29] "GET /socket.io/?EIO=3&transport=websocket&
sid=378063b0988c43149b90aecab5dac480 HTTP/1.1" 200 0 60.072800
Traceback (most recent call last):
File "c:\python34\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn
_n_impl
func(*args, **kwargs)
File "c:\python34\lib\site-packages\eventlet\wsgi.py", line 686, in process_re
quest
proto.__init__(sock, address, self)
File "c:\python34\lib\socketserver.py", line 675, in __init__
self.finish()
File "c:\python34\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "c:\python34\lib\site-packages\eventlet\greenio\base.py", line 469, in sh
utdown_safe
return sock.shutdown(socket.SHUT_RDWR)
OSError: [WinError 10038] An operation was attempted on something that is not a
socket
@artemiy-rodionov you do not have logs enabled, can't really see what's going on. Also, why are you using socket.io 1.2 client? That's old, I have actually never tested the 1.2 releases, the 1.3.x line have been in use for a long time now.
@miguelgrinberg
Actually I did not pay attention to socketio version. I upgraded it now to 1.4.3. Thanks for pointing me to it.
Here is the log. I could reproduce it only when disconnecting the client.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Administrator>run_server
Server initialized for eventlet.
* Restarting with stat
Server initialized for eventlet.
* Debugger is active!
* Debugger pin code: 200-501-276
(2296) wsgi starting up on http://127.0.0.1:5000/
(2296) accepted ('127.0.0.1', 50108)
(2296) accepted ('127.0.0.1', 50109)
(2296) accepted ('127.0.0.1', 50110)
(2296) accepted ('127.0.0.1', 50111)
(2296) accepted ('127.0.0.1', 50112)
(2296) accepted ('127.0.0.1', 50113)
127.0.0.1 - - [11/Jan/2016 20:21:58] "GET /task2 HTTP/1.1" 200 2789 0.014000
da4f02b11f684f1db6619cad77bfd49c: Sending packet OPEN with {'pingInterval': 2500
0, 'upgrades': ['websocket'], 'sid': 'da4f02b11f684f1db6619cad77bfd49c', 'pingTi
meout': 60000}
da4f02b11f684f1db6619cad77bfd49c: Sending packet MESSAGE with 0
127.0.0.1 - - [11/Jan/2016 20:21:59] "GET /socket.io/?EIO=3&transport=polling&t=
L8oMZQy HTTP/1.1" 200 381 0.022000
da4f02b11f684f1db6619cad77bfd49c: Received packet MESSAGE with 0/task2
da4f02b11f684f1db6619cad77bfd49c: Sending packet MESSAGE with 0/task2
127.0.0.1 - - [11/Jan/2016 20:21:59] "POST /socket.io/?EIO=3&transport=polling&t
=L8oMZSv&sid=da4f02b11f684f1db6619cad77bfd49c HTTP/1.1" 200 219 0.001000
127.0.0.1 - - [11/Jan/2016 20:21:59] "GET /socket.io/?EIO=3&transport=polling&t=
L8oMZS-&sid=da4f02b11f684f1db6619cad77bfd49c HTTP/1.1" 200 223 0.001000
(2296) accepted ('127.0.0.1', 50115)
da4f02b11f684f1db6619cad77bfd49c: Received request to upgrade to websocket
da4f02b11f684f1db6619cad77bfd49c: Sending packet NOOP with None
127.0.0.1 - - [11/Jan/2016 20:21:59] "GET /socket.io/?EIO=3&transport=polling&t=
L8oMZTB&sid=da4f02b11f684f1db6619cad77bfd49c HTTP/1.1" 200 215 0.324800
da4f02b11f684f1db6619cad77bfd49c: Upgrade to websocket successful
Client disconnected da4f02b11f684f1db6619cad77bfd49c
127.0.0.1 - - [11/Jan/2016 20:22:59] "GET /socket.io/?EIO=3&transport=websocket&
sid=da4f02b11f684f1db6619cad77bfd49c HTTP/1.1" 200 0 60.031800
Traceback (most recent call last):
File "c:\python34\lib\site-packages\eventlet\greenpool.py", line 82, in _spawn
_n_impl
func(*args, **kwargs)
File "c:\python34\lib\site-packages\eventlet\wsgi.py", line 686, in process_re
quest
proto.__init__(sock, address, self)
File "c:\python34\lib\socketserver.py", line 675, in __init__
self.finish()
File "c:\python34\lib\site-packages\eventlet\wsgi.py", line 603, in finish
greenio.shutdown_safe(self.connection)
File "c:\python34\lib\site-packages\eventlet\greenio\base.py", line 469, in sh
utdown_safe
return sock.shutdown(socket.SHUT_RDWR)
OSError: [WinError 10038] An operation was attempted on something that is not a
socket
Hope you have an idea where to dig in. I tried to debug eventlet lib but my only guess is that eventlet does not handle correctly closed socket on windows - https://github.com/eventlet/eventlet/blob/master/eventlet/greenio/base.py#L487
my only guess is that eventlet does not handle correctly closed socket on windows
Similar problems occur on Posix OSes, so this isn't strictly Windows. The errors are different for Posix, though.
Benign errors from web servers are captured in #160. Closing this one as a duplicate.
Having the below error messages appear in terminal.
when this happens the only way to connect again to app is to restart the app. My app does a screen refresh every 10 seconds, it's a dashboard. I've found it does this (fail) even when when not refreshing.
Attempt one is to try and configure a Apache web server front of FLASK and then port redirect ?
172.16.1.79 - - [25/May/2018 11:28:47] "GET /eftdashboard HTTP/1.1" 200 -
Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 261, in execute
write(data)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 224, in write
self.send_response(code, msg)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 337, in send_response
self.wfile.write(hdr.encode('ascii'))
IOError: [Errno 104] Connection reset by peer
172.16.71.55 - - [25/May/2018 11:28:47] "GET /eftdashboard HTTP/1.1" 200 -
172.16.71.197 - - [25/May/2018 11:28:47] "GET /eftdashboard HTTP/1.1" 200 -
Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 261, in execute
write(data)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 224, in write
self.send_response(code, msg)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 337, in send_response
self.wfile.write(hdr.encode('ascii'))
IOError: [Errno 32] Broken pipe
172.16.71.197 - - [25/May/2018 11:28:47] "GET / HTTP/1.1" 200 -
Package/version list.
[georgel@spr-oem-01 spr]$ pip list
Package Version
ansible 2.3.0.0
Babel 0.9.6
backports.ssl-match-hostname 3.4.0.2
click 6.7
configobj 4.7.2
cx-Oracle 6.2.1
decorator 3.4.0
ecdsa 0.13
ethtool 0.8
Fabric 1.6.2
Flask 0.12.2
httplib2 0.7.7
iniparse 0.4
itsdangerous 0.24
Jinja2 2.7.2
M2Crypto 0.21.1
MarkupSafe 0.11
ndg-httpsclient 0.4.2
paramiko 1.16.1
pciutils 1.7.3
perf 0.1
pip 10.0.1
pyasn1 0.1.9
pycrypto 2.6.1
pycurl 7.19.0
pygobject 3.14.0
pygpgme 0.3
pyliblzma 0.5.3
pyOpenSSL 0.13.1
pyTelegramBotAPI 2.1.6
python-dmidecode 3.10.13
python-dotenv 0.8.2
python-keyczar 0.71rc0
pyudev 0.15
pyxattr 0.5.1
PyYAML 3.10
requests 2.11.1
rhnlib 2.5.65
setuptools 0.9.8
six 1.9.0
slip 0.4.0
slip.dbus 0.4.0
urlgrabber 3.10
uWSGI 2.0.17
Werkzeug 0.14.1
yum-metadata-parser 1.1.4
comment ?
@georgelza The broken pipe error just indicates that the client closed an ongoing request, which is expected to happen a lot if you trigger refreshes every 10 seconds. You are using the Flask development web server for this, which is not a great choice, first because it is not a production grade web server, and second, because it does not support websocket.
I have a couple of suggestions for you:
Couple of questions, you say " You are using the Flask development web server" is there a production version ?
The refresh every 10 seconds is needed to update the screen with data from a database that is real time updated from 2 sources, which I then query and display.
As for the web server comment itself, we ended configuring an Apache web server in front of the Flask application.
I'll do some reading into the websocket enabled SocketIO ... you don't by any chance have a demo/example somewhere ?
is there a production version ?
No, you have to use a different web server for production, the one that comes with Flask is for development only. Eventlet has one, gevent has one, Gunicorn is also a good option. This is all explained in the deployment section of the Flask-SocketIO documentation: https://flask-socketio.readthedocs.io/en/latest/#deployment.
The refresh every 10 seconds is needed
You are wrong. There is no need to refresh the page to show new data. You can make dynamic updates to the same page using JavaScript. Refreshing the page every 10 seconds makes Flask-SocketIO useless. The whole point of Flask-SocketIO is to have a long term connection between the client and the server. A page refresh conflicts with that, because the browser closes all connections when the page changes.
As for the web server comment itself, we ended configuring an Apache web server in front of the Flask application.
Apache is not a supported webserver for Flask-SocketIO, when used properly (i.e. with a production async web server).
you don't by any chance have a demo/example somewhere ?
The example in this repository is a simple one that you can test. Note that to use websocket you just need to switch to a webserver that supports it, your application does not need to change.
Worried about the persistent connection, my client to server is over a unreliable network.
javascript, looks like I'm learning something new over the new couple of days. :)
Thanks for the ideas, will do some further reading.
Worried about the persistent connection, my client to server is over a unreliable network.
Then I would suggest that you use regular HTTP requests and not Flask-SocketIO. The main (and in most cases only) reason to use it is to have a long term connection where the server can push data to the client at any time.
I'd love to do that, def going to try, build some knowledge with regard to it, but as said the connection in this case is not 100% dependable, some non behaving firewalls in the middle that I can't get around that kill connections at random,
Most helpful comment
@miguelgrinberg
Actually I did not pay attention to socketio version. I upgraded it now to 1.4.3. Thanks for pointing me to it.
Here is the log. I could reproduce it only when disconnecting the client.
Hope you have an idea where to dig in. I tried to debug eventlet lib but my only guess is that eventlet does not handle correctly closed socket on windows - https://github.com/eventlet/eventlet/blob/master/eventlet/greenio/base.py#L487