Skip to content

Abrupt disconnection makes WebSocket server hang #24

@pzhlkj6612

Description

@pzhlkj6612

Killing the client (e.g., without calling DualClient::stop() ) makes subsequent re-connection to the server impossible.

s.set_close_handler([&](connection_hdl h) {
try {
const unsigned int socket_id = s.get_socket_id(h);
cb_.close(socket_id);
(void)ws_conns.erase(socket_id);
iprintf("closed conn {}", socket_id);
} catch (const std::exception& e) {
eprintf("close_handler: {}", e.what());
}
});

After adding some logs, I can see the WebSocket server stuck in the "close handler". Specifically, the std::map::erase() call didn't return.

I suspect that it's because of utility::worker_util in the SocketEntry, but utility::worker_util's destructor ended normally.

~worker_util() { work.push(work_item{true, {}, nullptr}); }

The log (omitted the timestamp and the only one thread):

INFO: websocket_server.cpp:operator():86 connection from 172.20.0.1
INFO: websocket_server.cpp:operator():86 connection from 172.20.0.1
INFO: websocket_server.cpp:operator():107 erase ing
INFO: auto_thread.hpp:~worker_util:58 dtor done
INFO: websocket_server.cpp:operator():109 erase done
INFO: websocket_server.cpp:operator():110 closed conn 424
INFO: websocket_server.cpp:operator():107 erase ing
INFO: auto_thread.hpp:~worker_util:58 dtor done
INFO: websocket_server.cpp:operator():109 erase done
INFO: websocket_server.cpp:operator():110 closed conn 400

INFO: websocket_server.cpp:operator():86 connection from 172.20.0.1
INFO: websocket_server.cpp:operator():86 connection from 172.20.0.1
INFO: websocket_server.cpp:operator():107 erase ing
INFO: auto_thread.hpp:~worker_util:58 dtor done

Debugging Win32 program in wine in Docker is painful to me. Since shmocz wrote:

The core component and it's related tests do not depend on Windows

from: README.md § Build core library natively without YRpp

I think I should be able to find the culprit easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions