Replies: 2 comments 4 replies
-
What is the code you have already? I suspect it writes the EOF when you successfully return from the handler. You can probably use something like request.transport.close() or something similar to abort the connection. |
Beta Was this translation helpful? Give feedback.
4 replies
-
I suspect there is something about the gunicorn deployment that interferes with that. Anyway, I was able to make it work with the following: close_tcp_connection(request.transport._sock)
(...)
def close_tcp_connection(sock):
"""Configure socket to close TCP connection immediately."""
try:
l_onoff = 1
l_linger = 0 # 0 seconds timeout - immediate close
sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", l_onoff, l_linger))
except (socket.error, OSError) as e:
log.warning(f"Error configuring socket for force close: {e}") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I have a request handler in my server that writes a chunked response to the client.
I want to be able to abort the underlying connection in case I detect I've sent some wrong data, so the client on the other side has a clue something went wrong.
I'm testing this with curl and noticed even if I don't call
response.write_eof()
, curl receives one:What is the appropriate way achieve that?
Beta Was this translation helpful? Give feedback.
All reactions