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

SSLError when trying to reply disconnected streaming client #3019

Open
lukjak opened this issue Jan 22, 2025 · 0 comments
Open

SSLError when trying to reply disconnected streaming client #3019

lukjak opened this issue Jan 22, 2025 · 0 comments

Comments

@lukjak
Copy link

lukjak commented Jan 22, 2025

python 3.12.8, werkzeug 3.1.3 on flask 3.1.0
(no issue with the previous setup: python 3.8, werkzeug 2.0.1 on flask 2.0.1 and the same flask app)

Conditions:

  • werkzeug runs with SSL certificates set up (ssl_context provided to make_server, also threaded=True)
  • there exists some specific network setup between werkzeug and connecting client; I haven't been able to reproduce the problem running the app locally and unfortunately I have no means to debug in the actual environment where the problem happens - I may try to check some specific things if needed
  • a flask route is set up to produce SSE-compatible streaming response (return Response(stream_with_context(my_data_generator(), mimetype="text/event-stream")), 200)

Error scenario:

  • a client successfully subscribes to the SSE stream (with GET /streaming-endpoint)
  • after some the client is shut down (it may have received some messages already or not)
  • my_data_generator() produces a new message
  • werkzeug always fails when attempting to send it to the now-dead client with the below:
[ERROR] (_internal.py/_log:97) Error on request:
Traceback (most recent call last):
  File "D:\CondaEnvs\default\Lib\site-packages\werkzeug\serving.py", line 370, in run_wsgi
    execute(self.server.app)
  File "D:\CondaEnvs\default\Lib\site-packages\werkzeug\serving.py", line 334, in execute
    write(data)
  File "D:\CondaEnvs\default\Lib\site-packages\werkzeug\serving.py", line 306, in write
    self.wfile.write(hex(len(data))[2:].encode())
  File "D:\CondaEnvs\default\Lib\socketserver.py", line 840, in write
    self._sock.sendall(b)
  File "D:\CondaEnvs\default\Lib\ssl.py", line 1210, in sendall
    v = self.send(byte_view[count:])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\CondaEnvs\default\Lib\ssl.py", line 1179, in send
    return self._sslobj.write(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
ssl.SSLError: [SYS] unknown error (_ssl.c:2417)

Expected:

  • the error is ignored
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

1 participant