Open achimnol opened 5 years ago
GitMate.io thinks the contributor most likely able to help you is @asvetlov.
Possibly related issues are https://github.com/aio-libs/aiohttp/issues/370 (Server closes connection before sending data), https://github.com/aio-libs/aiohttp/issues/3363 (How send "WebSocket Connection Close[FIN]"???), https://github.com/aio-libs/aiohttp/issues/2202 (Send explicit RuntimeError on response operations after session closing), https://github.com/aio-libs/aiohttp/issues/2309 (WebSocketResponse does not throw/close when connection is abruptly cut), and https://github.com/aio-libs/aiohttp/issues/172 (Question about ServerHttpProtocol.closing()).
I like the proposal but it is a backward incompatible change: a server code can get an unexpected exception on await ws.send_str('data')
.
Let's postpone the fix to aiohttp 4.0 (next version after 3.5 release)
I like the proposal but it is a backward incompatible change: a server code can get an unexpected exception on
await ws.send_str('data')
.Let's postpone the fix to aiohttp 4.0 (next version after 3.5 release)
@asvetlov Is there any updates for this issue ?
It is very annoying to have this workaround for socket.send() raised exception.
, because of silent affect
Long story short
In the server-side websocket handlers written with aiohttp,
WebSocketResponse
'ssend_xxx()
methods "ignores" closing/closed state of the connection.So in my code, I had to add
if ws.closed: break
everywhere that callssend_xxx()
.Maybe this issue is related to #2025.
Expected behaviour
The
send_xxx()
methods should raise an explicit exception so that a server-side task can notice if the connection is closed.Actual behaviour
The
send_xxx()
methods just emit an warning to the logger and continue. This behavior leads to a memory leak as the unsent messages accumulates in the buffer. I get a stream of log messages like:until my server-side task finishes (which runs without noticing the connection is closed!).
Steps to reproduce
asyncio.CancelledError
)Your environment
Linux & macOS.