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

While running a SSL server, responding an empty bytes causes an SSLEOFError. #1659

relent95 opened this issue Oct 22, 2019 · 3 comments


Copy link

Expected Behavior

In a request handler(endpoint), responding an empty bytes should be OK as in the following example.

@app.route('/test', methods = ['PUT'])
def test():
  return b'', 204 # HTTP_NO_CONTENT

Actual Behavior

But currently, this causes an SSLEOFError exception.

Error on request:
Traceback (most recent call last):
  File "/home/relent95/.local/lib/python3.5/site-packages/werkzeug/", line 303, in run_wsgi
  File "/home/relent95/.local/lib/python3.5/site-packages/werkzeug/", line 294, in execute
  File "/home/relent95/.local/lib/python3.5/site-packages/werkzeug/", line 275, in write
  File "/usr/lib/python3.5/", line 593, in write
    return self._sock.send(b)
  File "/usr/lib/python3.5/", line 861, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/", line 586, in write
    return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1848)


  • Python version: 3.5.2
  • Flask version: 1.1.1
  • Werkzeug version: 0.15.5
Copy link

greyli commented Nov 7, 2019

Hi, I can't reproduce your issue. I tested your code on Windows 10 and macOS with Python 3.5.2, Flask 1.1.1 and Werkzeug 0.15.5.

$ http put :5000/test
Content-Type: text/html; charset=utf-8
Date: Thu, 07 Nov 2019 14:02:29 GMT
Server: Werkzeug/0.15.5 Python/3.5.2

@davidism davidism transferred this issue from pallets/flask Nov 7, 2019
Copy link

relent95 commented Nov 7, 2019

Hi, this problem occurs only when you run the SSL server.

Copy link

nmoehrle commented Dec 9, 2019

Ran into the same issue when flask was responding with 304 to static file requests - Not Modified. The fix works for me :-) Thank you!

@davidism davidism added this to the 0.16.1 milestone Jan 4, 2020
@davidism davidism closed this as completed Jan 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

5 participants