Open XDinEuro opened 1 year ago
+1
probably you need to accept the connection and close it from listener
Hello guys,
TLDR:
socket.getConnection().invalidate();
sendClose
just sends a close frame to peer. Then peer has to respond with close frame too.
And only after that both sides actually close the connection. - this is the "graceful way".
But the point is that it isn't always possible to follow graceful way due to multiple reasons:
Your server has to account for all this (using pings/pongs) and drop bad clients.
How to drop connection:
socket.getConnection().invalidate();
Hi, I am using oatpp-websocket example from https://github.com/oatpp/example-websocket/blob/master/.
I have one use case, the server need to decline new connection when there exists two client.
I tried to change the code here from
to
It works properly at first few attemps, but after few times the server stop responding to any connections even though I disconnect the previous two clients.
Another issue is, after I call
socket.sendClose()
,WSInstanceListener::onBeforeDestroy()
is not triggered. Thus I need to manually doSOCKETS = 2
.Is there is better way to gracefully cut down the connections, or more straghtforward,
Is there a way to reject coming connections ?