SocketRocket - Invalid Sec-WebSocket-Accept

When I try to connect to a custom socket server using SocketRocket, I get an error message:

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

I associated this with the _checkHandshake method in _HTTPHeadersDidFinish. The _checkHandshake method does the following:

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

I found this question and have the latest socketrocket, but it doesn't seem to work?

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

Please let me know how to get around this error (SocketRocket - Invalid Sec-WebSocket-Accept)

+3
source share
1 answer

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

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

:

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

the error has disappeared.

+6
source

All Articles