IXWebSocket icon indicating copy to clipboard operation
IXWebSocket copied to clipboard

Host HTTP and WS on the same port

Open TheArtfulBodger opened this issue 2 years ago • 7 comments

This is a PR to allow for WS and HTTP to be run on the same port. I'm looking to fix the merge conflicts and tidy up a bit

TheArtfulBodger avatar Oct 02 '22 09:10 TheArtfulBodger

Running tests...
Test project /home/tab/Code/IXWebSocket/_build
      Start  1: IXSocketTest
 1/16 Test  #1: IXSocketTest .................................   Passed    0.00 sec
      Start  2: IXSocketConnectTest
 2/16 Test  #2: IXSocketConnectTest ..........................   Passed    1.16 sec
      Start  3: IXWebSocketServerTest
 3/16 Test  #3: IXWebSocketServerTest ........................   Passed    4.81 sec
      Start  4: IXWebSocketTestConnectionDisconnection
 4/16 Test  #4: IXWebSocketTestConnectionDisconnection .......   Passed   12.75 sec
      Start  5: IXUrlParserTest
 5/16 Test  #5: IXUrlParserTest ..............................   Passed    0.01 sec
      Start  6: IXHttpClientTest
 6/16 Test  #6: IXHttpClientTest .............................   Passed   57.32 sec
      Start  7: IXUnityBuildsTest
 7/16 Test  #7: IXUnityBuildsTest ............................   Passed    0.00 sec
      Start  8: IXHttpTest
 8/16 Test  #8: IXHttpTest ...................................   Passed    0.00 sec
      Start  9: IXDNSLookupTest
 9/16 Test  #9: IXDNSLookupTest ..............................   Passed    3.36 sec
      Start 10: IXWebSocketSubProtocolTest
10/16 Test #10: IXWebSocketSubProtocolTest ...................   Passed    0.01 sec
      Start 11: IXStrCaseCompareTest
11/16 Test #11: IXStrCaseCompareTest .........................   Passed    0.00 sec
      Start 12: IXExponentialBackoffTest
12/16 Test #12: IXExponentialBackoffTest .....................   Passed    0.00 sec
      Start 13: IXWebSocketCloseTest
13/16 Test #13: IXWebSocketCloseTest .........................   Passed    7.54 sec
      Start 14: IXHttpServerTest
14/16 Test #14: IXHttpServerTest .............................   Passed    0.09 sec
      Start 15: IXWebSocketChatTest
15/16 Test #15: IXWebSocketChatTest ..........................   Passed    2.22 sec
      Start 16: IXWebSocketPerMessageDeflateCompressorTest
16/16 Test #16: IXWebSocketPerMessageDeflateCompressorTest ...   Passed    0.00 sec

100% tests passed, 0 tests failed out of 16

Total Test time (real) =  89.28 sec

It appears to pass all the tests, does the IXHttpClientTest normally take around a minute or has this been affected by the PR?

TheArtfulBodger avatar Oct 02 '22 09:10 TheArtfulBodger

Having done some work with it, I'm getting some unresolved externals, I'm looking at a fix

main.obj : error LNK2001: unresolved external symbol "public: static int const ix::SocketServer::kDefaultTcpBacklog" 
main.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const ix::SocketServer::kDefaultMaxConnections"
main.obj : error LNK2001: unresolved external symbol "public: static int const ix::SocketServer::kDefaultAddressFamily" 
main.obj : error LNK2001: unresolved external symbol "public: static int const ix::WebSocketServer::kDefaultHandShakeTimeoutSecs" 
main.obj : error LNK2001: unresolved external symbol "private: static int const ix::HttpServer::kDefaultTimeoutSecs"
fatal error LNK1120: 5 unresolved externals [D:\a\Thing-Downloader\Thing-Downloader\_build\tdd\tdd.vcxproj]

Update: I think it's an unrelated issue, and goes away when it's compiled statically

TheArtfulBodger avatar Oct 02 '22 15:10 TheArtfulBodger

Maybe those constants should become something simpler like go in the anonymous namespace, to get rid of those weird problems.

bsergean avatar Oct 05 '22 23:10 bsergean

This is a great feature and improvement, but I think we're going to need some docs and unittest before merging, because it would be easy to break it.

bsergean avatar Oct 05 '22 23:10 bsergean

Also having a new sub-command, or something to exercise this code in the ws test program would be nice. This is how I do most of my interactive testing.

Maybe a websocket echo server, that can also serve files, or return an 'OK' or 'Ping' when an http request is made to it at /ping

bsergean avatar Oct 05 '22 23:10 bsergean

The runtime of one minute for the http client unittest is suspicious.

bsergean avatar Oct 05 '22 23:10 bsergean

I fired the unittest on the PR.

bsergean avatar Oct 05 '22 23:10 bsergean

Thanks for the contribution ! If you can write a unittest that would be appreciated.

bsergean avatar Nov 06 '22 01:11 bsergean