Does anyone know why a .send() would block indefin...
# ktor
i
Does anyone know why a .send() would block indefinitely on the outbound channel of a WebSocket connection? I’m not seeing anything to indicate that the websocket has closed.
d
It shouldn’t happen as far as I know. Can you provide more information to reproduce it? A sample code and steps for getting this behavior?
i
May be tricky but I can try. Does the fact that calling offer() returns true a bunch of times, but then returns false with isFull returning true only after offer() has been called and returning false?
d
why do you need offer?
i
I just tried it as an experiment because send() was blocking.
Also, a correction, it looks like isFull() is true before offer is called - so it just looks like the outbound channel is filling up to its buffer size, but it looks like it’s not being emptied by anything.
d
maybe the part that is consuming it, is broken
if you can reproduce it consistently with a simple snippet, that would help a lot
i
I can try that but it may be tricky as this is currently happening in the middle of a large codebase. Looking in my debugger the outgoingToBeProcessed ArrayChannel is at capacity, 8, so it does look like whatever is pulling messages from that and sending them may have stopped, but I don’t see any exceptions
d
let me check the code handling websockets to see if it is swallowing exceptions
as far as I understand, on exception, the socket is closed
so might be a bug
^^ @e5l
i
Hmm, I don’t see why it would silently swallow an exception
d
no, it doesn’t seems the case, but still something strange is happening, right?
i
Yeah, I can confirm that the message prior to isFull being true was sent and received, so it appears like it was transmitted without being removed from the outgoing queue
d
I would fill an issue here: https://github.com/ktorio/ktor/issues With all the information you have, and if you manage to consistently or almost consistently reproduce it with a short isolated sample, would be super.
👀 1
e
I’m not seeing anything to indicate that the websocket has closed.
It look's like a bug.
i
@e5l Any tips on how to track it down? I’m hoping to avoid trying to whittle it down to a simple test case as that could require quite a bit of scaffolding. Definitely looks like messages are being sent over the websocket without being removed from the outgoing message queue - which then fills up
…checking to see whether it happens after the same number of messages are sent
no, it occurs after a variable number of messages, typically around 20 (so some are being removed from the outbound buffer, just not all)
FYI - issue created here. I need to focus on something else today but I can try to create a simple repeatable use-case. If this bug is affecting other people then it could be causing a lot of headaches. https://github.com/ktorio/ktor/issues/462
If any of you guys have any ideas for quick things I can check please let me know