diff --git a/cocos/network/WebSocket.cpp b/cocos/network/WebSocket.cpp index 3b5b3559f7..3705fb2219 100644 --- a/cocos/network/WebSocket.cpp +++ b/cocos/network/WebSocket.cpp @@ -442,6 +442,14 @@ void WebSocket::onSubThreadStarted() _wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection, _path.c_str(), _host.c_str(), _host.c_str(), name.c_str(), -1); + + if(NULL == _wsInstance) { + WsMessage* msg = new WsMessage(); + msg->what = WS_MSG_TO_UITHREAD_ERROR; + _readyState = kStateClosing; + _wsHelper->sendMessageToUIThread(msg); + } + } }