{"action":"created","issue":{"url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/issues/200","repository_url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO","labels_url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/issues/200/comments","events_url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/issues/200/events","html_url":"https://github.com/miguelgrinberg/Flask-SocketIO/issues/200","id":125774782,"number":200,"title":"Client refresh produces exception in the server","user":{"login":"JohnHardy","id":1375329,"avatar_url":"https://avatars2.githubusercontent.com/u/1375329?v=4","gravatar_id":"","url":"https://api.github.com/users/JohnHardy","html_url":"https://github.com/JohnHardy","followers_url":"https://api.github.com/users/JohnHardy/followers","following_url":"https://api.github.com/users/JohnHardy/following{/other_user}","gists_url":"https://api.github.com/users/JohnHardy/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnHardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnHardy/subscriptions","organizations_url":"https://api.github.com/users/JohnHardy/orgs","repos_url":"https://api.github.com/users/JohnHardy/repos","events_url":"https://api.github.com/users/JohnHardy/events{/privacy}","received_events_url":"https://api.github.com/users/JohnHardy/received_events","type":"User","site_admin":false},"labels":[{"id":79522647,"url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-01-09T19:01:27Z","updated_at":"2018-05-25T22:41:37Z","closed_at":"2016-03-24T17:44:05Z","author_association":"NONE","body":"TL;DR: Pressing F5 on the client generates a bunch of tracebacks in the server:\n\n```\npackages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n```\n\nI have a minimal client and server running on Windows 10 and Google Chrome.\n\n``` javascript\n      var socket = io.connect({\n          'sync disconnect on unload': true // makes no difference if in or out\n        });\n```\n\n``` python\n# Setup\nflask = Flask(__name__)\nsio = SocketIO(flask)\nsio.run(flask)\n\n# Hooks\n@sio.on('connect')\ndef connect_client():\n    log.info('websocket client connected from \"%s\"' % flask.request.sid)\n\n@sio.on('disconnect')\ndef disconnected_client():\n    log.info('websocket client disconnected from \"%s\"' % flask.request.sid)\n```\n\nEverything is normal when launching the server.\n\n```\n(env) C:\\Users\\John\\Documents\\GitHub\\platform-client [master +1 ~5 -0 !]> python .\\run.py\nengineio    : INFO     Server initialized for eventlet.\nwerkzeug    : INFO      * Restarting with stat\nengineio    : INFO     Server initialized for eventlet.\nwerkzeug    : WARNING   * Debugger is active!\nwerkzeug    : INFO      * Debugger pin code: 127-711-505\n(4668) wsgi starting up on http://127.0.0.1:5000/\n```\n\nEverything is normal connecting a client:\n\n```\n(4668) accepted ('127.0.0.1', 62050)\n(4668) accepted ('127.0.0.1', 62051)\n(4668) accepted ('127.0.0.1', 62052)\n(4668) accepted ('127.0.0.1', 62053)\n(4668) accepted ('127.0.0.1', 62054)\n(4668) accepted ('127.0.0.1', 62055)\napp.dashboard.dashboard: INFO     hit route\n127.0.0.1 - - [09/Jan/2016 18:45:32] \"GET / HTTP/1.1\" 200 8970 0.017155\nengineio    : INFO     38161f6c34914de39690a41195734749: Sending packet OPEN with {'upgrades': ['websocket'], 'pingTimeout': 60000, 'sid': '38161f6c34914de39690a41195734749', 'pingInterval': 25000}\napp.sockets : INFO     websocket client connected from \"38161f6c34914de39690a41195734749\"\nengineio    : INFO     38161f6c34914de39690a41195734749: Sending packet MESSAGE with 0\n127.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\n(4668) accepted ('127.0.0.1', 62058)\nengineio    : INFO     38161f6c34914de39690a41195734749: Received request to upgrade to websocket\nengineio    : INFO     38161f6c34914de39690a41195734749: Sending packet NOOP with None\n127.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\nengineio    : INFO     38161f6c34914de39690a41195734749: Upgrade to websocket successful\nengineio    : INFO     38161f6c34914de39690a41195734749: Received packet PING with None\nengineio    : INFO     38161f6c34914de39690a41195734749: Sending packet PONG with None\n```\n\nWhen I press F5 in the browser, I get the following errors:\n\n```\napp.dashboard.dashboard: INFO     hit route\n127.0.0.1 - - [09/Jan/2016 18:45:57] \"GET / HTTP/1.1\" 200 8970 0.007009\napp.sockets : INFO     websocket client disconnected from \"38161f6c34914de39690a41195734749\"\n127.0.0.1 - - [09/Jan/2016 18:45:58] \"GET /static/css/fonts.css HTTP/1.1\" 304 250 0.002503\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n(4668) accepted ('127.0.0.1', 62065)\n(4668) accepted ('127.0.0.1', 62066)\n(4668) accepted ('127.0.0.1', 62067)\n(4668) accepted ('127.0.0.1', 62068)\n(4668) accepted ('127.0.0.1', 62069)\n127.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\n127.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\n127.0.0.1 - - [09/Jan/2016 18:45:58] \"GET /dashboard/static/css/sidebar.css HTTP/1.1\" 304 250 0.001502\n127.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\n127.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\n127.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\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n(4668) accepted ('127.0.0.1', 62070)\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\nengineio    : INFO     c0be9cda97ab43f5b967c7c59c9e3d76: Sending packet OPEN with {'upgrades': ['websocket'], 'pingTimeout': 60000, 'sid': 'c0be9cda97ab43f5b967c7c59c9e3d76', 'pingInterval': 25000}\napp.sockets : INFO     websocket client connected from \"c0be9cda97ab43f5b967c7c59c9e3d76\"\nengineio    : INFO     c0be9cda97ab43f5b967c7c59c9e3d76: Sending packet MESSAGE with 0\n127.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\n127.0.0.1 - - [09/Jan/2016 18:45:58] \"GET /static/img/favicon.ico HTTP/1.1\" 200 1916 0.002009\n(4668) accepted ('127.0.0.1', 62073)\n(4668) accepted ('127.0.0.1', 62074)\nengineio    : INFO     c0be9cda97ab43f5b967c7c59c9e3d76: Received request to upgrade to websocket\nengineio    : INFO     c0be9cda97ab43f5b967c7c59c9e3d76: Sending packet NOOP with None\n127.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\nengineio    : INFO     c0be9cda97ab43f5b967c7c59c9e3d76: Upgrade to websocket successful\n```\n\nI 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\n\nWhen I close a browser window, the disconnect seems to be fine  - but a few seconds later I get this:\n\n```\napp.sockets : INFO     websocket client disconnected from \"a446831595b346cdaf751d7c0ab667a9\"\n127.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\nTraceback (most recent call last):\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenpool.py\", line 82, in _spawn_n_impl\n    func(*args, **kwargs)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 686, in process_request\n    proto.__init__(sock, address, self)\n  File \"c:\\python35\\Lib\\socketserver.py\", line 686, in __init__\n    self.finish()\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\wsgi.py\", line 603, in finish\n    greenio.shutdown_safe(self.connection)\n  File \"C:\\Users\\John\\Documents\\GitHub\\platform-client\\env\\lib\\site-packages\\eventlet\\greenio\\base.py\", line 469, in shutdown_safe\n    return sock.shutdown(socket.SHUT_RDWR)\nOSError: [WinError 10038] An operation was attempted on something that is not a socket\n```\n\n```\nApiDoc==1.2\neventlet==0.17.4\nFlask==0.10.1\nFlask-Assets==0.11\nFlask-Bower==1.2.1\nFlask-SocketIO==1.2\ngreenlet==0.4.9\nitsdangerous==0.24\nJinja2==2.8\njsmin==2.2.0\njsonschema==2.3.0\nMarkupSafe==0.23\npython-engineio==0.8.5\npython-socketio==0.8.2\nPyYAML==3.10\nsimplejson==3.8.1\nsix==1.10.0\nwebassets==0.11.1\nWerkzeug==0.11.3\nwheel==0.24.0\n```\n\nAny thoughts?  Thanks very much!\n"},"comment":{"url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/issues/comments/392205642","html_url":"https://github.com/miguelgrinberg/Flask-SocketIO/issues/200#issuecomment-392205642","issue_url":"https://api.github.com/repos/miguelgrinberg/Flask-SocketIO/issues/200","id":392205642,"user":{"login":"miguelgrinberg","id":2715854,"avatar_url":"https://avatars0.githubusercontent.com/u/2715854?v=4","gravatar_id":"","url":"https://api.github.com/users/miguelgrinberg","html_url":"https://github.com/miguelgrinberg","followers_url":"https://api.github.com/users/miguelgrinberg/followers","following_url":"https://api.github.com/users/miguelgrinberg/following{/other_user}","gists_url":"https://api.github.com/users/miguelgrinberg/gists{/gist_id}","starred_url":"https://api.github.com/users/miguelgrinberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miguelgrinberg/subscriptions","organizations_url":"https://api.github.com/users/miguelgrinberg/orgs","repos_url":"https://api.github.com/users/miguelgrinberg/repos","events_url":"https://api.github.com/users/miguelgrinberg/events{/privacy}","received_events_url":"https://api.github.com/users/miguelgrinberg/received_events","type":"User","site_admin":false},"created_at":"2018-05-25T22:41:37Z","updated_at":"2018-05-25T22:41:37Z","author_association":"OWNER","body":"> Worried about the persistent connection, my client to server is over a unreliable network.\r\n\r\nThen 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."}}
{"actor":{"display_login":"miguelgrinberg"}}