Websocket crash on server close

Websocket crash on server close
0.0 0


I have a turn based multiplayer game. So when i see an inactive user i kick him of the server (close the websocket connection from the server). For some reason this causes a crash on ios (i have NOT tested other devices) about 80-90% of the time.

I am sorry if the issue has been reported allredy.

BTW i am useing tomcats websocket server

Screenshot attached (file Websocket.cpp) :slight_smile:

Screen Shot 2013-09-10 at 7.37.11 PM.png (31.7 KB)


So the way i do this i have a ccbi scene that opens a WS connection to the server /login and after they login and start the game i close that WS connection on client and start a new scene that opens a connection to /game. THEN when i close my websocket connection on the server i get that crash.

So i saw that void WebSocket::onSubThreadEnded() is empty anyway so just comment the crashing line out. Seems to fix it :slight_smile:


I’m so sorry to see that…

void WsThreadHelper::quitSubThread()
    _needQuit = true;  // this may be called when connection is close, and then _ws must be deleted.
    // set _needQuit true is not safe enough to ensure _ws lives after wsThreadEntryFunc exiting...
    // may be we should block here until wsThreadEntryFunc thread end

void* WsThreadHelper::wsThreadEntryFunc(void* arg)

    while (!_needQuit)
        if (_ws->onSubThreadLoop())

    _ws->onSubThreadEnded();  // this code run after quitSubThread(), and most of the time _ws is deleted

    return (void*)0;

By the way,onSubThreadEnded is a virtual function, commenting the line is a bad solution…
Will this issue be fixed in next release?


There’s pending PR related to this issue.