{"action":"created","issue":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/699","repository_url":"https://api.github.com/repos/warmcat/libwebsockets","labels_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/699/labels{/name}","comments_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/699/comments","events_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/699/events","html_url":"https://github.com/warmcat/libwebsockets/issues/699","id":192738583,"number":699,"title":"unknow opcode 0xB","user":{"login":"kjnoh77","id":15315820,"avatar_url":"https://avatars.githubusercontent.com/u/15315820?v=3","gravatar_id":"","url":"https://api.github.com/users/kjnoh77","html_url":"https://github.com/kjnoh77","followers_url":"https://api.github.com/users/kjnoh77/followers","following_url":"https://api.github.com/users/kjnoh77/following{/other_user}","gists_url":"https://api.github.com/users/kjnoh77/gists{/gist_id}","starred_url":"https://api.github.com/users/kjnoh77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjnoh77/subscriptions","organizations_url":"https://api.github.com/users/kjnoh77/orgs","repos_url":"https://api.github.com/users/kjnoh77/repos","events_url":"https://api.github.com/users/kjnoh77/events{/privacy}","received_events_url":"https://api.github.com/users/kjnoh77/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-12-01T02:27:20Z","updated_at":"2016-12-01T09:09:23Z","closed_at":"2016-12-01T02:41:13Z","body":"\r\nHere is our user code using libwebsockets.\r\nI generate two port by using lws_create_vhost().(one is secure and the other is non-secure port)\r\nI believe two service will working at same thread.\r\nBut, still it looks like that client sometimes receive unexpected opcode=0xB.\r\nCould you review this user code?\r\n\r\n============================================\r\n\r\n#include <dlog.h>\r\n#include <pthread.h>\r\n#include <json/json.h>\r\n#include <sdp/sdp_api.h>\r\n#include <ss/ss_api.h>\r\n\r\n//#define DUMP_HANDSHAKE_INFO\r\n\r\nstd::string Server::serverPort;\r\nchar* Server::private_key_pw = NULL;\r\n\r\nstd::map<struct lws*, Websocket*> Server::InstanceMap;\r\nstd::map<Websocket*, void*> Server::WebsocketAliveMap;\r\n\r\nstd::map<struct lws*, HttpMessage*> Server::HttpInstanceMap;\r\nstd::map<HttpMessage*, void*> Server::HttpAliveMap;\r\n\r\nvoid Server::dump_handshake_info(struct lws *wsi)\r\n{\r\n\tint n = 0, len;\r\n\tchar buf[256];\r\n\tconst unsigned char *c;\r\n\r\n\tdo {\r\n\t\tc = lws_token_to_string((lws_token_indexes)n);\r\n\t\tif (!c) {\r\n\t\t\tn++;\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tlen = lws_hdr_total_length(wsi, (lws_token_indexes)n);\r\n\t\tif (!len || (unsigned int)len > sizeof(buf) - 1) {\r\n\t\t\tn++;\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tlws_hdr_copy(wsi, buf, sizeof buf, (lws_token_indexes)n);\r\n\t\tbuf[sizeof(buf) - 1] = '\\0';\r\n\r\n\t\tPGM_DLOG_INFO(\"%s = %s\", (char *)c, buf);\r\n\t\tn++;\r\n\t} while (c);\r\n}\r\n\r\nint Server::callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)\r\n{\r\n\tswitch (reason) {\r\n\t\tcase LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION\");\r\n\t\t\t\tchar Buf[128] = {0,};\r\n\t\t\t\tmemset(Buf, 0, sizeof(Buf));\r\n\t\t\t\tlws_hdr_copy(wsi, Buf, sizeof(Buf), WSI_TOKEN_PROTOCOL);\r\n\t\t\t\tPGM_DLOG_INFO(\"protocol is '%s'\", Buf);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_ESTABLISHED:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : ESTABLISHED (wsi:0x%x)\", wsi);\r\n\r\n#ifdef DUMP_HANDSHAKE_INFO\r\n\t\t\t\tdump_handshake_info(wsi);\r\n#endif\r\n\r\n\t\t\t\tWebsocket* pWebsocket = new Websocket(wsi);\r\n\t\t\t\tif (pWebsocket == NULL) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot create new instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tInstanceMap.insert({wsi, pWebsocket});\r\n\r\n\t\t\t\tWebsocketAliveMap.insert({pWebsocket, NULL});\r\n\r\n\t\t\t\tif (connection == \"Upgrade\") {\r\n          Channel::onSocketConnection(pWebsocket, path.c_str());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_RECEIVE:\r\n\t\t\t{\r\n\t\t\t\t//PGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_RECEIVE\");\r\n\r\n\t\t\t\tif (InstanceMap.find(wsi) == InstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tWebsocket* pWebsocket = (InstanceMap.find(wsi))->second;\r\n\r\n\t\t\t\tif (lws_remaining_packet_payload(wsi) == 0) { // recieved all data\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tChannel::onSocketMessage(pWebsocket, (const char*)(pWebsocket->ReceiveBuf), pWebsocket->ReceivedLength, lws_frame_is_binary(wsi));\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// cleanup receive buffer\r\n\t\t\t\t\tif (pWebsocket->ReceiveBuf) {\r\n\t\t\t\t\t\tfree(pWebsocket->ReceiveBuf);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tpWebsocket->ReceiveBuf = (unsigned char*)calloc(1, sizeof(char));\r\n\t\t\t\t\tpWebsocket->ReceivedLength = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_RECEIVE_PONG:\r\n\t\t\t{\r\n\t\t\t\t//PGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_RECEIVE_PONG\");\r\n\r\n\t\t\t\tif (InstanceMap.find(wsi) == InstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tWebsocket* pWebsocket = (InstanceMap.find(wsi))->second;\r\n\r\n\t\t\t\tpWebsocket->numberNotAck = 0;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_SERVER_WRITEABLE:\r\n\t\t\t{\r\n\t\t\t\t//PGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_SERVER_WRITEABLE\");\r\n\r\n\t\t\t\tif (InstanceMap.find(wsi) == InstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tWebsocket* pWebsocket = (InstanceMap.find(wsi))->second;\r\n\r\n\t\t\t\tif (pWebsocket->CloseRequest) {\r\n\t\t\t\t\tPGM_DLOG_INFO(\"'%s' will be closed(wsi:0x%x)\", pWebsocket->GetID().c_str(), wsi);\r\n\t\t\t\t\tRemoveWebsocket(wsi);\r\n\t\t\t\t\treturn -1; // to close this wsi\r\n\t\t\t\t}\r\n\r\n\t\t\t\tpthread_mutex_lock(&pWebsocket->SendBufMutex);\r\n\t\t\t\twhile (pWebsocket->SendBuf_Q.begin() != pWebsocket->SendBuf_Q.end()) {\r\n\t\t\t\t\tSendBufList::iterator itr = pWebsocket->SendBuf_Q.begin();\r\n\t\t\t\t\t_SendBufInfo SendBufInfo = *itr;\r\n\t\t\t\t\tpWebsocket->SendBuf_Q.erase(itr);\r\n\r\n\t\t\t\t\tbool BinaryFlag = SendBufInfo.BinaryFlag;\r\n\t\t\t\t\tbool IsPingpongSend = SendBufInfo.IsPingpongSend;\r\n\t\t\t\t\tunsigned char* SendBuf = SendBufInfo.SendBuf;\r\n\t\t\t\t\tint SendLength = SendBufInfo.SendLength;\r\n\t\t\t\t\tint MsgId = SendBufInfo.MsgId;\r\n\r\n\t\t\t\t\tif (SendBuf == NULL) {\r\n\t\t\t\t\t\tPGM_DLOG_INFO(\"Send Buf is NULL\");\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (SendLength == 0) {\r\n\t\t\t\t\t\tPGM_DLOG_INFO(\"Send Length is 0\");\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tint n = 0;\r\n\r\n\t\t\t\t\tif (BinaryFlag) {\r\n\t\t\t\t\t\tn = lws_write(wsi, &(SendBuf[LWS_SEND_BUFFER_PRE_PADDING]), SendLength, LWS_WRITE_BINARY);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tn = lws_write(wsi, &(SendBuf[LWS_SEND_BUFFER_PRE_PADDING]), SendLength, LWS_WRITE_TEXT);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (n < 0) {\r\n\t\t\t\t\t\tPGM_DLOG_FATAL(\"socket write failed. Msg ID:%d, To:'%s'\", MsgId, pWebsocket->GetID().c_str());\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tif ((pWebsocket->ForDevLogging == false) && (IsPingpongSend == false)) {\r\n\t\t\t\t\t\t\tPGM_DLOG_INFO(\"Msg ID:%d, Length:%d, To:'%s'\", MsgId, n, pWebsocket->GetID().c_str());\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// cleanup write buffer\r\n\t\t\t\t\tif ((SendBuf != NULL)) {\r\n\t\t\t\t\t\tfree(SendBuf);\r\n\t\t\t\t\t\tSendBuf = NULL;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tpthread_mutex_unlock(&pWebsocket->SendBufMutex);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_CLOSED:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_CLOSED (wsi:0x%x)\", wsi);\r\n\t\t\t\tRemoveWebsocket(wsi);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_CLIENT_RECEIVE_PONG:\r\n\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_CLIENT_RECEIVE_PONG\");\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_HTTP:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_HTTP (wsi:0x%x)\", wsi);\r\n\r\n#ifdef DUMP_HANDSHAKE_INFO\r\n\t\t\t\tdump_handshake_info(wsi);\r\n#endif\r\n\r\n\t\t\t\tHttpMessage* pHttpMessage;\r\n\t\t\t\tif (HttpInstanceMap.find(wsi) == HttpInstanceMap.end()) {\r\n\t\t\t\t\tpHttpMessage = new HttpMessage(wsi);\r\n\t\t\t\t\tif (pHttpMessage == NULL) {\r\n\t\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot create new instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tHttpInstanceMap.insert({wsi, pHttpMessage});\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tpHttpMessage = (HttpInstanceMap.find(wsi))->second;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tHttpAliveMap.insert({pHttpMessage, NULL});\r\n\r\n\t\t\t\tpHttpMessage->AnalyzeRequest();\r\n\r\n\t\t\t\tif (pHttpMessage->ReqBodyExist == false) {\r\n\t\t\t\t\tpHttpMessage->onHTTPRequest();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_HTTP_BODY:\r\n\t\t\t{\r\n\t\t\t\t//PGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_HTTP_BODY (wsi:0x%x)\", wsi);\r\n\r\n\t\t\t\tif (HttpInstanceMap.find(wsi) == HttpInstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tHttpMessage* pHttpMessage = (HttpInstanceMap.find(wsi))->second;\r\n\r\n\t\t\t\tpHttpMessage->ReqBodyTmp = (unsigned char*)realloc(pHttpMessage->ReqBodyTmp, pHttpMessage->ReqBodyLengthTmp + len);\r\n\t\t\t\tmemcpy(&(pHttpMessage->ReqBodyTmp[pHttpMessage->ReqBodyLengthTmp]), (char*)in, len);\r\n\t\t\t\tpHttpMessage->ReqBodyLengthTmp = pHttpMessage->ReqBodyLengthTmp + len;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_HTTP_BODY_COMPLETION:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_HTTP_BODY_COMPLETION (wsi:0x%x)\", wsi);\r\n\r\n\t\t\t\tif (HttpInstanceMap.find(wsi) == HttpInstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tHttpMessage* pHttpMessage = (HttpInstanceMap.find(wsi))->second;\r\n\r\n\t\t\t\tpHttpMessage->ReqBody = (unsigned char*)calloc(pHttpMessage->ReqBodyLengthTmp, sizeof(char));\r\n\t\t\t\tmemcpy(pHttpMessage->ReqBody, pHttpMessage->ReqBodyTmp, pHttpMessage->ReqBodyLengthTmp);\r\n\t\t\t\tpHttpMessage->ReqBodyLength = pHttpMessage->ReqBodyLengthTmp;\r\n\r\n\t\t\t\tPGM_DLOG_DEBUG(\"HTTP REQ BODY length = %d\", pHttpMessage->ReqBodyLength);\r\n\r\n\t\t\t\tpHttpMessage->onHTTPRequest();\r\n\r\n\t\t\t\t// cleanup tmp receive buffer\r\n\t\t\t\tif (pHttpMessage->ReqBodyTmp) {\r\n\t\t\t\t\tfree(pHttpMessage->ReqBodyTmp);\r\n\t\t\t\t\tpHttpMessage->ReqBodyTmp = NULL;\r\n\t\t\t\t}\r\n\t\t\t\tpHttpMessage->ReqBodyTmp = (unsigned char*)calloc(1, sizeof(char));\r\n\t\t\t\tpHttpMessage->ReqBodyLengthTmp = 0;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_HTTP_WRITEABLE:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_HTTP_WRITEABLE (wsi:0x%x)\", wsi);\r\n\r\n\t\t\t\tif (HttpInstanceMap.find(wsi) == HttpInstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tHttpMessage* pHttpMessage = (HttpInstanceMap.find(wsi))->second;\r\n\r\n\t\t\t\tint n = lws_write(wsi, pHttpMessage->ResponseBody, pHttpMessage->ResponseBodyLength, LWS_WRITE_HTTP);\r\n\t\t\t\tif (n == pHttpMessage->ResponseBodyLength) {\r\n\t\t\t\t\tPGM_DLOG_DEBUG(\"success for 'Requested Id : %d' (written length=%d)\", \r\n\t\t\t\t\t\t\t\t\tpHttpMessage->RequestedId, n);\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error for 'Requested Id : %d' (req length=%d, written length=%d)\",\r\n\t\t\t\t\t\t\t\t\tpHttpMessage->RequestedId, pHttpMessage->ResponseBodyLength, n);\r\n\t\t\t\t}\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase LWS_CALLBACK_CLOSED_HTTP:\r\n\t\t\t{\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : LWS_CALLBACK_CLOSED_HTTP (wsi:0x%x)\", wsi);\r\n\r\n\t\t\t\tif (HttpInstanceMap.find(wsi) == HttpInstanceMap.end()) {\r\n\t\t\t\t\tPGM_DLOG_FATAL(\"error : cannot find instance for this wsi(0x%x)\", wsi);\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t\tHttpMessage* pHttpMessage = (HttpInstanceMap.find(wsi))->second;\r\n\t\t\t\tHttpInstanceMap.erase(HttpInstanceMap.find(wsi));\r\n\r\n\t\t\t\tif (HttpAliveMap.find(pHttpMessage) != HttpAliveMap.end()) {\r\n\t\t\t\t\tHttpAliveMap.erase(HttpAliveMap.find(pHttpMessage));\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdelete pHttpMessage;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tdefault:\r\n\t\t\tif ((reason != LWS_CALLBACK_GET_THREAD_ID) && (reason != LWS_CALLBACK_CHANGE_MODE_POLL_FD) &&\r\n\t\t\t\t(reason != LWS_CALLBACK_LOCK_POLL) && (reason != LWS_CALLBACK_UNLOCK_POLL)) {\r\n\t\t\t\tPGM_DLOG_INFO(\"SERVER : %d\", reason);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n      :\r\nvoid* Server::ServerThread(void* data)\r\n{\r\n\tstatic struct lws_protocols protocols[] = {\r\n\t\t/* first protocol must always be HTTP handler */\r\n\t\t{\r\n\t\t\t\"http-only\",\t\t/* name */\r\n\t\t\tcallback_http,\t\t/* callback */\r\n\t\t\tsizeof (struct per_session_data__http),\t/* per_session_data_size */\r\n\t\t\t0,\t\t\t/* max frame size / rx buffer */\r\n\t\t},\r\n\t\t{\r\n\t\t\tNULL,\t\t/* name */\r\n\t\t\tcallback_null,\t\t/* callback */\r\n\t\t\t0,\t/* per_session_data_size */\r\n\t\t\t0,\t\t\t/* max frame size / rx buffer */\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"msf-2\",\r\n\t\t\tcallback_msf2,\r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t},\r\n\t\t{ // for c# client\r\n\t\t\t\"basic\",\r\n\t\t\tcallback_basic,\r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"dumb-increment-protocol\",\r\n\t\t\tcallback_dumb_increment,\r\n\t\t\tsizeof(struct per_session_data__dumb_increment),\r\n\t\t\t10,\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"lws-mirror-protocol\",\r\n\t\t\tcallback_lws_mirror,\r\n\t\t\tsizeof(struct per_session_data__lws_mirror),\r\n\t\t\t128,\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"lws-echogen\",\r\n\t\t\tcallback_lws_echogen,\r\n\t\t\tsizeof(struct per_session_data__echogen),\r\n\t\t\t128,\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"lws-status\",\r\n\t\t\tcallback_lws_status,\r\n\t\t\tsizeof(struct per_session_data__lws_status),\r\n\t\t\t128,\r\n\t\t},\r\n\t\t{ NULL, NULL, 0, 0 } /* terminator */\r\n\t};\r\n\r\n\tint use_ssl = 0;\r\n\tint n = 0;\r\n\t// int ret = 0;\r\n\r\n\tstruct lws_context *context;\r\n\r\n\tstruct lws_context_creation_info info;\r\n\r\n\tmemset(&info, 0, sizeof info);\r\n\tinfo.port = WEBSOCKET_SERVER_SECURE_PORT;\r\n\tinfo.protocols = protocols;\r\n\tinfo.extensions = NULL;\r\n\tinfo.ssl_cert_filepath = CERT_PATH;\r\n\tinfo.ssl_private_key_filepath = PRIVATE_KEY_PATH;\r\n\tinfo.ssl_private_key_password = private_key_pw;\r\n\tinfo.ssl_ca_filepath = CA_PATH;\r\n\tinfo.ssl_cipher_list = \"ECDHE-RSA-AES256-SHA384:\"\r\n\t\t\t\t\t\t\"DHE-RSA-AES256-SHA384:\"\r\n\t\t\t\t\t\t\"ECDHE-RSA-AES256-SHA256:\"\r\n\t\t\t\t\t\t\"DHE-RSA-AES256-SHA256:\"\r\n\t\t\t\t\t\t\"ECDHE-RSA-AES128-SHA256:\"\r\n\t\t\t\t\t\t\"DHE-RSA-AES128-SHA256:\"\r\n\t\t\t\t\t\t\"HIGH:\"\r\n\t\t\t\t\t\t\"!aNULL:\"\r\n\t\t\t\t\t\t\"!eNULL:\"\r\n\t\t\t\t\t\t\"!EXPORT:\"\r\n\t\t\t\t\t\t\"!DES:\"\r\n\t\t\t\t\t\t\"!RC4:\"\r\n\t\t\t\t\t\t\"!MD5:\"\r\n\t\t\t\t\t\t\"!PSK:\"\r\n\t\t\t\t\t\t\"!SRP:\"\r\n\t\t\t\t\t\t\"!CAMELLIA:\"\r\n\t\t\t\t\t\t\"!DES-CBC3-SHA:\"\r\n\t\t\t\t\t\t\"!ECDHE-RSA-DES-CBC3-SHA\";\r\n\tinfo.gid = -1;\r\n\tinfo.uid = -1;\r\n\tinfo.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;\r\n\tinfo.user = 0;\r\n\r\n#ifndef LWS_NO_EXTENSIONS\r\n\t// info.extensions = lws_get_internal_extensions();\r\n#endif\r\n\tcontext = lws_create_context(&info);\r\n\r\n\tif (context == NULL) {\r\n\t\tPGM_DLOG_INFO(\"create_websocket context failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tmemset(&info, 0, sizeof info);\r\n\tinfo.port = WEBSOCKET_SERVER_PORT;\r\n\tinfo.protocols = protocols;\r\n\tinfo.extensions = NULL;\r\n\tinfo.ssl_cert_filepath = NULL;\r\n\tinfo.ssl_private_key_filepath = NULL;\r\n\tinfo.gid = -1;\r\n\tinfo.uid = -1;\r\n\tinfo.options = LWS_SERVER_OPTION_EXPLICIT_VHOSTS;\r\n\tinfo.user = 0;\r\n\r\n\tlws_create_vhost(context, &info);\r\n\r\n\tn = 0;\r\n\t// loop until socket closed\r\n\twhile (n >= 0) {\r\n\t\tn = lws_service(context, 0x0FFFFFFF);\r\n\t}\r\n\r\n\tPGM_DLOG_INFO(\"create_websocket destroy context\");\r\n\r\n\tif (context)\r\n\t\tlws_context_destroy(context);\r\n\r\n\treturn NULL;\r\n}\r\n\r\nstd::string Server::Port()\r\n{\r\n\treturn serverPort;\r\n}\r\n\r\nvoid Server::Start()\r\n{\r\n\tchar port[10] = {0,};\r\n\tsnprintf((char *)port, sizeof(port), \"%d\", WEBSOCKET_SERVER_PORT);\r\n\tserverPort = port;\r\n\r\n\tpthread_t ServerThreadID;\r\n\tint status = pthread_create(&ServerThreadID, NULL, ServerThread, NULL);\r\n\tpthread_detach(ServerThreadID);\r\n\r\n\tPGM_DLOG_INFO(\"'%s' server thread created\", port);\r\n}\r\n"},"comment":{"url":"https://api.github.com/repos/warmcat/libwebsockets/issues/comments/264119211","html_url":"https://github.com/warmcat/libwebsockets/issues/699#issuecomment-264119211","issue_url":"https://api.github.com/repos/warmcat/libwebsockets/issues/699","id":264119211,"user":{"login":"lws-team","id":15154525,"avatar_url":"https://avatars.githubusercontent.com/u/15154525?v=3","gravatar_id":"","url":"https://api.github.com/users/lws-team","html_url":"https://github.com/lws-team","followers_url":"https://api.github.com/users/lws-team/followers","following_url":"https://api.github.com/users/lws-team/following{/other_user}","gists_url":"https://api.github.com/users/lws-team/gists{/gist_id}","starred_url":"https://api.github.com/users/lws-team/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lws-team/subscriptions","organizations_url":"https://api.github.com/users/lws-team/orgs","repos_url":"https://api.github.com/users/lws-team/repos","events_url":"https://api.github.com/users/lws-team/events{/privacy}","received_events_url":"https://api.github.com/users/lws-team/received_events","type":"User","site_admin":false},"created_at":"2016-12-01T09:09:23Z","updated_at":"2016-12-01T09:09:23Z","body":"Does the original test server have the same problem, when running in ssl mode?"}}
{"actor":{"display_login":"lws-team"}}