Websocket4Net only receive reply for the first message

420 Views Asked by At

I'm connecting to a server using Websocket4Net, when I send a message, I receive the reply for that message, when I send a second message, I do net get the reply!

When I restart the connection, and send the second message again, I receive the reply!

So, within the same session, I only receive a reply for the first sent message, and not for second, third, etc...

This is the code I use to connect to the server:

    WSIWebSocket = New WebSocket(FinalURL)
    WSIWebSocket.Security.AllowNameMismatchCertificate = True
    WSIWebSocket.Security.AllowCertificateChainErrors = True
    WSIWebSocket.Security.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls
    WSIWebSocket.Security.AllowUnstrustedCertificate = True
    AddHandler WSIWebSocket.Opened, AddressOf WSIWebSocket_Opened
    AddHandler WSIWebSocket.Error, AddressOf WSIWebSocket_Error
    AddHandler WSIWebSocket.Closed, AddressOf WSIWebSocket_Closed
    AddHandler WSIWebSocket.MessageReceived, AddressOf WSIWebSocket_MessageReceived
    WSIWebSocket.Open()
1

There are 1 best solutions below

0
On

I have found the reason why I do not get the reply for the second message, in the first message reply, I do connect to DB2 database, where the app hangs for some seconds, which cause the web socket object to not able to send keep alive pings, and will be considered as disconnected by the server.