[WebSocket] Better detect transition to STATE_CLOSING
When wslay receives a message that is too big it automatically sends a close request to the remote peer with code 1009 (Message Too Big) but it also completely stop calling the receive callback resulting in the state being "stuck" as CONNECTED (even if both client and server have disconnected). We now check if we sent such a close message and manually transition to the "closed" state with the proper reason.
This commit is contained in:
parent
3576e840c7
commit
a1ef068b77
1 changed files with 16 additions and 6 deletions
|
@ -689,12 +689,22 @@ void WSLPeer::poll() {
|
|||
close(-1);
|
||||
return;
|
||||
}
|
||||
if (wslay_event_get_close_sent(wsl_ctx) && wslay_event_get_close_received(wsl_ctx)) {
|
||||
// Clean close.
|
||||
wslay_event_context_free(wsl_ctx);
|
||||
wsl_ctx = nullptr;
|
||||
close(-1);
|
||||
return;
|
||||
if (wslay_event_get_close_sent(wsl_ctx)) {
|
||||
if (wslay_event_get_close_received(wsl_ctx)) {
|
||||
// Clean close.
|
||||
wslay_event_context_free(wsl_ctx);
|
||||
wsl_ctx = nullptr;
|
||||
close(-1);
|
||||
return;
|
||||
} else if (wslay_event_get_status_code_sent(wsl_ctx) == WSLAY_CODE_MESSAGE_TOO_BIG) {
|
||||
// wslay seems to completely stop processing incoming events after receiving a message that's too big.
|
||||
close_reason = "Message Too Big";
|
||||
close_code = 1009;
|
||||
wslay_event_context_free(wsl_ctx);
|
||||
wsl_ctx = nullptr;
|
||||
close(-1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue