Skip to content

the client did not receive the close event #474

Open

Description

@engun

System: Windows 11 64-bit.

This lib is great. Although there were some issues encountered during use

When the server is abnormally shut down, the client did not receive the close event. It seems that the FD_CLOSE event should be taken into account in WSAWaitForMultipleEvents in IXNetSystem::poll.

Activity

  1. bsergean commented on Jul 1, 2023

    @bsergean
    Collaborator

    Thanks for the good words, it's possible there are some holes in the IXNetSystem::poll.

    If you want to submit a PR we can try to evaluate it and merge it.

    I code on macOS and Linux, so I'm not the best person to fix advanced windows problem sadly.

  2. dacap commented on Aug 22, 2023

    @dacap
    Contributor

    It's probable that there is a missing wakeUpFromPoll() call from WebSocketTransport::close() to unlock the WebSocket::stop() function which is waiting for a _thread.join() (this thread is running WebSocket::run() which calls WebSocketTransport::poll() that can be waken up only if wakeUpFromPoll() is called again):

    diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp
    index ec25465..8049fb6 100644
    --- a/ixwebsocket/IXWebSocketTransport.cpp
    +++ b/ixwebsocket/IXWebSocketTransport.cpp
    @@ -1174,7 +1174,10 @@ namespace ix
         {
             _requestInitCancellation = true;
     
    -        if (_readyState == ReadyState::CLOSING || _readyState == ReadyState::CLOSED) return;
    +        if (_readyState == ReadyState::CLOSING || _readyState == ReadyState::CLOSED) {
    +            wakeUpFromPoll(SelectInterrupt::kSendRequest);
    +            return;
    +        }
     
             if (closeWireSize == 0)
             {
  3. bsergean commented on Aug 23, 2023

    @bsergean
    Collaborator

    @dacap If you make a PR for this change we can give it a try on CI.

  4. Longwater1234 commented on Jul 9, 2024

    @Longwater1234

    This problem still persists even with latest version. Only on Windows. On MacOS it alright.

  5. bsergean commented on May 14, 2025

    @bsergean
    Collaborator

    Might be fixed with #548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions