{"action":"created","issue":{"url":"https://api.github.com/repos/zeekay/flask-uwsgi-websocket/issues/30","labels_url":"https://api.github.com/repos/zeekay/flask-uwsgi-websocket/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/zeekay/flask-uwsgi-websocket/issues/30/comments","events_url":"https://api.github.com/repos/zeekay/flask-uwsgi-websocket/issues/30/events","html_url":"https://github.com/zeekay/flask-uwsgi-websocket/issues/30","id":84514239,"number":30,"title":"uwsgi_response_write_body_do() erros","user":{"login":"HackerMD","id":6855297,"avatar_url":"https://avatars.githubusercontent.com/u/6855297?v=3","gravatar_id":"","url":"https://api.github.com/users/HackerMD","html_url":"https://github.com/HackerMD","followers_url":"https://api.github.com/users/HackerMD/followers","following_url":"https://api.github.com/users/HackerMD/following{/other_user}","gists_url":"https://api.github.com/users/HackerMD/gists{/gist_id}","starred_url":"https://api.github.com/users/HackerMD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackerMD/subscriptions","organizations_url":"https://api.github.com/users/HackerMD/orgs","repos_url":"https://api.github.com/users/HackerMD/repos","events_url":"https://api.github.com/users/HackerMD/events{/privacy}","received_events_url":"https://api.github.com/users/HackerMD/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-03T11:43:53Z","updated_at":"2015-06-12T08:40:38Z","closed_at":null,"body":"Sometimes I get the following errors:\r\n```\r\nuwsgi_response_write_body_do(): Broken pipe [core/writer.c line 419] during GET /output (127.0.0.1)\r\n```\r\nor\r\n```\r\nuwsgi_websockets_recv_pkt(): Connection reset by peer [core/websockets.c line 194] during GET /output (127.0.0.1)\r\n```\r\nor \r\n```\r\nuwsgi_response_write_body_do(): Protocol wrong type for socket [core/writer.c line 419] during GET /output (127.0.0.1)\r\n```\r\n\r\nThe above listed errors seem to only occur for process that require a long time to compute. Weirdly, I get different errors when I simply re-run the same request.\r\n\r\nThis is the code (exemplified) that I'm running on server (the code itself runs without error):\r\n```{python}\r\nfrom flask import Flask\r\nfrom flask.ext.uwsgi_websocket import GeventWebSocket\r\n\r\napp = Flask('myApp', static_folder=cfg.CLIENT_DIR_LOCATION, static_url_path='')\r\nws = GeventWebSocket(app)\r\n\r\n@ws.route('/output')\r\ndef run_job(ws):\r\n   while True:\r\n        message = ws.receive()\r\n        if message:\r\n            send_data = json.loads(message)\r\n            data = send_data['data']\r\n            # Then I run some code in a loop and return the output\r\n           for i in data:\r\n               output = i\r\n               ws.send(json.dumps({\r\n                        'event': 'output',\r\n                        'data': output\r\n               }))\r\n```\r\n\r\nAnd I run the app as follows:\r\n```\r\napp.run(debug=True, port=8000, gevent=100)\r\n```\r\n\r\nHow can I prevent this from happening?"},"comment":{"url":"https://api.github.com/repos/zeekay/flask-uwsgi-websocket/issues/comments/111415136","html_url":"https://github.com/zeekay/flask-uwsgi-websocket/issues/30#issuecomment-111415136","issue_url":"https://api.github.com/repos/zeekay/flask-uwsgi-websocket/issues/30","id":111415136,"user":{"login":"HackerMD","id":6855297,"avatar_url":"https://avatars.githubusercontent.com/u/6855297?v=3","gravatar_id":"","url":"https://api.github.com/users/HackerMD","html_url":"https://github.com/HackerMD","followers_url":"https://api.github.com/users/HackerMD/followers","following_url":"https://api.github.com/users/HackerMD/following{/other_user}","gists_url":"https://api.github.com/users/HackerMD/gists{/gist_id}","starred_url":"https://api.github.com/users/HackerMD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackerMD/subscriptions","organizations_url":"https://api.github.com/users/HackerMD/orgs","repos_url":"https://api.github.com/users/HackerMD/repos","events_url":"https://api.github.com/users/HackerMD/events{/privacy}","received_events_url":"https://api.github.com/users/HackerMD/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T08:40:37Z","updated_at":"2015-06-12T08:40:37Z","body":"I'm using version **2.0.10**.\r\n\r\nI was in the meanwhile able to solve the `uwsgi_response_write_body_do()` problem. This was somehow related to my client side ([ngWebsocket](https://github.com/wilk/ng-websocket)) disconnecting. Why the client disconnected is not clear to me, however.\r\n\r\nWorth mentioning could be that I'm calling [subprocess32](https://pypi.python.org/pypi/subprocess32/) with Popen at \"# Then I run some code in a loop and return the output\" and it seems that the errors occur when processes take longer to compute."}}