0

I'm developing a windows desktop application WebSocket client, I use WebSocket-Sharp nuget to connect to the server.

My problem is when the connection is Idle for some time, my client will not send any pong responses to server ping requests, by checking Fiddler (screenshot below) you can see that third server ping request always will hang and no response will be sent.

enter image description here

I try to send ping requests from my client to server every 10 seconds (rather than waiting server to send ping every 20 seconds), by checking Fiddler I can see that my client is sending ping requests to server and server response properly, but actually after a small period of Idle time (around 30 seconds) my client ping requests result is False (which mean they failed).

Update 1: I forget to mention that when I test server using "Simple Web Socket Client" Chrome extension it is working fine with no issues.

My questions are:

  • Does anybody know how I can troubleshoot or solve thisproblem in websocket-sharp nuget?
  • Do you recommend any other nuget package or should I build my cleint from scratch rather than depending on third-party libraries?
Ebraheem
  • 603
  • 6
  • 24
  • 1
    Try two things 1) use cmd.exe >Netstat -a which will give status on connection to see if the connection closed 2) Check Fiddler for FIN which indicates the connection closed. The server may be closing connection when idle so you may need to enable the Keep-Alive when client connects. – jdweng Apr 02 '18 at 09:27
  • Thank you for your reply, I will check your recommendations and let you know the result, but I forget to mention in the question that when I try to connect to same server using "Simple Web Socket client" Chrome browser extension it is working fine. – Ebraheem Apr 02 '18 at 09:31
  • I perform steps you mentioned and found the following. 1) connection state is LISTENING. 2) by checking Fiddler logs I found the following 2 errors - 12:37:27:2535 [WebSocket #1904] Read from Server returned error: 0 - 12:37:27:2535 [WebSocket #1904] Read from Client failed... Object reference not set to an instance of an object. – Ebraheem Apr 02 '18 at 09:43
  • It looks like the server is listening but the client connection failed. A webconnection uses TCP as transport layer so every web connection also has a TCP. TCP has max size of 1500 bytes so for every http message you will see multiple TCP messages. A server can have multiple clients connect so I can't tell if the client is really connect. I would sniffer the Chrome Connection and see what headers are being used. I suspect you need to add the Chrome headers to your http request. – jdweng Apr 02 '18 at 09:51
  • 1
    Thank you very much for your answers that were helpful in troubleshooting the problem. it seems that I was use a cloned version from WebSocket-Sharp, i replace dlls from official github site and all issues had been resolved. It's my mistake I had to be more concentrated. – Ebraheem Apr 05 '18 at 06:47

0 Answers0