Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uwsgi_response_write_body_do() erros #30

Open
hackermd opened this issue Jun 3, 2015 · 2 comments
Open

uwsgi_response_write_body_do() erros #30

hackermd opened this issue Jun 3, 2015 · 2 comments

Comments

@hackermd
Copy link

hackermd commented Jun 3, 2015

Sometimes I get the following errors:

uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 419] during GET /output (127.0.0.1)

or

uwsgi_websockets_recv_pkt(): Connection reset by peer [core/websockets.c line 194] during GET /output (127.0.0.1)

or

uwsgi_response_write_body_do(): Protocol wrong type for socket [core/writer.c line 419] during GET /output (127.0.0.1)

The 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.

This is the code (exemplified) that I'm running on server (the code itself runs without error):

from flask import Flask
from flask.ext.uwsgi_websocket import GeventWebSocket

app = Flask('myApp', static_folder=cfg.CLIENT_DIR_LOCATION, static_url_path='')
ws = GeventWebSocket(app)

@ws.route('/output')
def run_job(ws):
   while True:
        message = ws.receive()
        if message:
            send_data = json.loads(message)
            data = send_data['data']
            # Then I run some code in a loop and return the output
           for i in data:
               output = i
               ws.send(json.dumps({
                        'event': 'output',
                        'data': output
               }))

And I run the app as follows:

app.run(debug=True, port=8000, gevent=100)

How can I prevent this from happening?

@zeekay
Copy link
Owner

zeekay commented Jun 12, 2015

What version of uwsgi are you using?

@hackermd
Copy link
Author

I'm using version 2.0.10.

I was in the meanwhile able to solve the uwsgi_response_write_body_do() problem. This was somehow related to my client side (ngWebsocket) disconnecting. Why the client disconnected is not clear to me, however.

Worth mentioning could be that I'm calling 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants