6

尝试使用 SocketRocket 连接到自定义套接字服务器时,出现错误:

Error Domain=SRWebSocketErrorDomain Code=2133 "Invalid Sec-WebSocket-Accept response" UserInfo=0x8f6af00 {NSLocalizedDescription=Invalid Sec-WebSocket-Accept response}

我已将此链接回 _HTTPHeadersDidFinish 中的 _checkHandshake 方法。_checkHandshake 方法执行以下操作:

NSString *acceptHeader = CFBridgingRelease(CFHTTPMessageCopyHeaderFieldValue(httpMessage, CFSTR("Sec-WebSocket-Accept")));

我找到了这个问题,并且拥有最新版本的 socketrocket,但似乎无法正常工作?

https://github.com/square/SocketRocket/issues/24

请告诉我如何解决此错误(SocketRocket - Invalid Sec-WebSocket-Accept)

4

1 回答 1

10

I confirm that (using a SockJS server) by changing this:

    NSURL *url = [NSURL URLWithString:@"http://localhost:9090"];

to this:

    NSURL *url = [NSURL URLWithString:@"http://localhost:9090/websocket"];

the error was gone.

于 2014-04-25T17:07:16.017 回答