Registration disabled at the moment Read more...
×


FrozenK
Members-
Content Count
3 -
Joined
-
Last visited
Everything posted by FrozenK
-
Websocket server/client frame sending rate issue
FrozenK posted a topic in ICS - Internet Component Suite
Hello, I'm using the ICS 9.0 C++ package. While testing a websocket server (TSslHttpAppSrv) communication with a client (TSslWebSocketCli), I noticed that both have trouble receiving several frames in a short period. It doesn't seems to be related to the frame size because sending empty text frames (using WSSendText) doesn't change anything. Let's suppose I want to send 10 messages from my server to my client, in my small test program I can : a) click 10 times on a "send" button. b) click one time on a "send" button but then I loop 10 times on WSSendText. In the (a) scenario everything is ok but in the (b) scenario the connection is closed at some point, attaching a TIcsLogger to the server and client does not really help as you can see below : Server side LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TriggerDataSent handle=1476 LoggerLogEvent : 11:00:15:084 00000148B13008B0 TCustomWSocket.Shutdown 1 handle=1476 "11:00:15.084" : WS ClientDisconnect : 0 Client side LoggerLogEvent : 11:00:15:084 SessionClosed Error: 0 LoggerLogEvent : 11:00:15:084 00000204E35B5B30 TCustomWSocket.Shutdown 1 handle=1468 These tests are done without SSL. Now if I activate SSL, both (a) and (b) scenarios works fine, I do not have any sudden connection close anymore. My understanding is that the extra computation introduced by the transport layer security adds a delay before sending the frame (or maybe the way frames are sent is reorganised) so the client has now time to process each frame without being flooded. I'm a bit surprised because these numbers are quite low (10 frames), I actually doesn't have to send 10 frames to create the issue 3 is enough. I have the feeling that I'm missing something, either on the server/client configuration side (a missing parameter ?) or on the feedback informations (from the logger) that I get preventing me to understand exactly what is going on. If someone has a clue on what should I do to get a better grasp on my problem it would be very much appreciated. Thanks in advance. -
Websocket client and server configuration issue
FrozenK posted a topic in ICS - Internet Component Suite
Hello, I'm trying to configure the most simple websocket client (with TSslWebSocketCli) and server (with TSslHttpAppSrv) in order to get them communicate with each other locally. Worth noting that I'm a beginner in the internet communication protocol world, this is why I'm trying to get the minimum working and then I will build from that. I'm using the ICS 9.0 C++ package, I believe I have a configuration problem more than a C++ problem. For the client part, I configured the following (no TLS for now) : client->SocketFamily = sfAnyIPv4; client->DebugLevel = DebugHdr; client->CertVerMethod = CertVerNone; client->SslCliSecurity = sslCliSecDefault; client->URL = "ws://127.0.0.1/"; client->WSPingSecs = 10; event handlers to get something printed in the terminal : client->OnHttpRestProg = HttpRestProg; client->OnWSFrameRcvd = FrameRcvd; client->OnWSConnected = Connected; client->OnWSDisconnected = Disconnected; For the server part, based on the Delphi samples OverbyteIcsBasicWebServer1.pas and OverbyteIcsSslMultiWebServ.pas, I configured : server->AuthRealm = "ics"; server->SocketErrs = wsErrFriendly; server->ExclusiveAddr = true; server->SessionTimeout = 300; server->MaxSessions = 100; server->OnDisplay = Display; server->SslEnable = false; server->SslCliCertMethod = sslCliCertNone; server->SslCertAutoOrder = false; server->CertExpireDays = 30; server->OcspSrvStapling = false; server->AddGetAllowedPath("/", afBeginBy, "WEB-APP"); server->OnClientConnect = ClientConnect; I added an host : server->IcsHosts->Clear(); TIcsHost *host = new TIcsHost(server->IcsHosts); host->HostEnabled = true; host->HostNames->Text = "localhost"; host->HostTag = "WEB-APP"; host->Descr = "WebApp Server"; host->BindIpAddr = "127.0.0.1"; host->BindNonPort = 80; host->BindSslPort = 0; host->WebDefDoc = "index.html"; host->WebDocDir = dir + "data"; When the client is connecting (TSslWebSocketCli.WSConnect), OnClientConnect is triggered server side, then : THttpWSSrvConn *conn = (THttpWSSrvConn *)Client; conn->WSessionCookie = "OverbyteIcsWebAppServer" + server->Port; conn->OnWSLogEvent = ClientLogEvent; conn->OnWSHandshake = ClientHandShake; conn->OnWSDisconnected = ClientDisconnected; conn->OnWSFrameRcvd = ClientFrameRcvd; conn->OnWSFrameSent = ClientFrameSent; conn->OnWSReady = ClientReady; conn->OnWSPingTimer = ClientPingTimer; conn->OnBgException = ClientBgException; Then the server handle the request (these are called : THttpConnection::ProcessRequest(), ::ProcessGet(), ::ProcessGetHeadDel(), ::SendDocument()...) and returns an "HTTP/1.1 200 OK" response to the client. From TSslWebSocketCli.WSConnect I get "WebSocket: Failed to Connect:" but the LastResponse string is empty. It looks like the server treats my websocket upgrade request as a "classic" request, so it returns an "HTTP/1.1 200 OK" response instead of the expected "HTTP/1.1 101 Switching Protocols". To make sure my client part was ok, I quickly tried it on a node.js websocket server, no problem, I get the "101 Switching Protocols" response and the websocket connection is established. If I do not use TSslWebSocketCli.WSConnect but do a "manual" GET with an upgrade request header and on server side add an url handler (TUrlHandlerIndexHtml) and send a response header through AnswerStream, the connection is established. But if I send frames from the client, OnWSFrameRcvd is not triggred server side (as expected I believe since server has no clue I handled the upgrade "myself"). Hopefully this post makes sense, in short, I don't understand why my upgrade request on url: "ws://127.0.0.1/" fails on the ICS server, any help would be appreciated. Thanks in advance. -
Websocket client and server configuration issue
FrozenK replied to FrozenK's topic in ICS - Internet Component Suite
Thanks a lot for your help Angus. After I modified the path and also specified "THttpWSSrvConn" as the "server->ClientClass" (whichi I missed), it is now working fine. Happy Holiday season.