我有一个c#客户端,我正在尝试连接到websocket服务器。使用Chrome扩展程序"简单Web客户端客户端",我可以连接,并将命令发送到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,并且连接时也遇到了问题。