IXWebSocket icon indicating copy to clipboard operation
IXWebSocket copied to clipboard

IXWebSocketServer Timeout Problems....

Open PatchByte opened this issue 3 years ago • 12 comments

How would you implement a callback into the IXWebSocketServer for timeouts?

Because i need to deallocate memory when a client timeouts / disconnects. But the problem is i never get like a disconnect message or error message when a client timeouts in the client message callback!

Am i doing something wrong?

PatchByte avatar Nov 18 '22 21:11 PatchByte

So i have looked further into this. If you force close the application it (the client), the server will not get like a error nor a close message and also the ConnectionState does not deallocate!!

PatchByte avatar Nov 19 '22 15:11 PatchByte

But if you have a Web Browser (ex.: FireFox, Chrome etc.) and you call the .close method it will throw a Close Message in the server handler.

PatchByte avatar Nov 19 '22 15:11 PatchByte

so with repeating printf debugging i narrowed down the problem to .poll, well seems logical.

PatchByte avatar Nov 19 '22 15:11 PatchByte

I mean WebSocketTransport::poll()

PatchByte avatar Nov 19 '22 15:11 PatchByte

so with more printf debugging i narrowed down the problem to Socket::isReadyToRead

PatchByte avatar Nov 19 '22 15:11 PatchByte

So i have tested it more and the problem only occurs in window machines. So i would guess its a winsocks problem. Yay Windows

PatchByte avatar Nov 19 '22 17:11 PatchByte

There was a patch which is windows only a while ago, it seemed to improve things but you could try to revert it, or use the version right before. However there has always been one problem on windows, which is why some unittest are disabled. (check in the cmakelist.txt for the tests, you could try to un-comment them). However you seem to already have a repro case.

bsergean avatar Nov 22 '22 05:11 bsergean

@PatchByte did you found a solution?

C0kkie avatar Sep 24 '23 13:09 C0kkie

or @bsergean is there a solution?

C0kkie avatar Sep 24 '23 13:09 C0kkie

there were a few related commits recently, for windows, you might want to try again with latest master

bsergean avatar Sep 24 '23 14:09 bsergean

For anyone who is stumbling on this:

  • Make a Ping Pong System with a timeout
  • If a certain amount of time has passed without a ping then just disconnect the client

PatchByte avatar Oct 08 '23 12:10 PatchByte

(This is a temporary fix, until IXWebSocket fixes this issue, I have no clue what is causing this, but it seems to be an implementation problem with WinSocks as far as I could guess)

PatchByte avatar Oct 08 '23 12:10 PatchByte