1

我正在使用 Websocket4Net 连接到服务器,当我发送一条消息时,我收到了该消息的回复,当我发送第二条消息时,我确实得到了回复!

当我重新启动连接并再次发送第二条消息时,我收到了回复!

所以,在同一个会话中,我只收到第一条发送消息的回复,而不是第二条、第三条等的回复……

这是我用来连接服务器的代码:

    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()
4

1 回答 1

1

我找到了我没有收到第二条消息回复的原因,在第一条消息回复中,我确实连接到 DB2 数据库,应用程序在该数据库中挂起几秒钟,这导致 Web 套接字对象无法发送 keep活着的 ping,并且将被服务器视为断开连接。

于 2018-10-02T21:27:46.147 回答