0

我有 ac# 客户端,我正在尝试连接到 websocket 服务器。使用 Chrome 扩展程序“Simple Web Socket Client”,我可以连接并将命令正常发送到 websocket 服务器,因此我知道服务器工作正常并且它是一个商业产品。

我正在尝试使用库 WebSocketSharp,但在尝试连接到套接字时出现此错误。只是为了让您知道没有代理服务器在运行,并且服务器位于内部网络上。

2/03/2018 4:05:00 PM|Fatal|WebSocket.Connect|WebSocketSharp.WebSocketException: An exception has occurred while reading an HTTP request/response. ---> System.FormatException: Input string was not in a correct format.
                          at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String argument)
                          at System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent)
                          at System.Version.TryParseVersion(String version, VersionResult& result)
                          at System.Version.Parse(String input)
                          at System.Version..ctor(String version)
                          at WebSocketSharp.HttpResponse.Parse(String[] headerParts)
                          at WebSocketSharp.HttpBase.Read[T](Stream stream, Func`2 parser, Int32 millisecondsTimeout)
                          --- End of inner exception stack trace ---
                          at WebSocketSharp.HttpBase.Read[T](Stream stream, Func`2 parser, Int32 millisecondsTimeout)
                          at WebSocketSharp.HttpRequest.GetResponse(Stream stream, Int32 millisecondsTimeout)
                          at WebSocketSharp.WebSocket.sendHttpRequest(HttpRequest request, Int32 millisecondsTimeout)
                          at WebSocketSharp.WebSocket.sendHandshakeRequest()
                          at WebSocketSharp.WebSocket.doHandshake()
                          at WebSocketSharp.WebSocket.connect()

使用wireshark我跟随流并将其作为握手的一部分

  GET / HTTP/1.1
  User-Agent: websocket-sharp/1.0
  Host: 192.168.0.29:55537
  Upgrade: websocket
  Connection: Upgrade
  Sec-WebSocket-Key: o0Smz22nOFWLW/3hvyvYQQ==
  Sec-WebSocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover
  Sec-WebSocket-Version: 13

  ....HTTP/1.1 101 Switching Protocols
  Connection: Upgrade
  Upgrade: websocket
  Sec-WebSocket-Accept: guJWynqtY1ZrPq+m6bfUGE2yJvA=

任何想法?我什至尝试过 WebSocket4Net 并且连接也有问题。

4

0 回答 0