Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SocketRocket - Invalid Sec-WebSocket-Accept

When trying to connect to a custom socket server using SocketRocket I am getting the error:

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

I have linked this back to the _checkHandshake method in _HTTPHeadersDidFinish. The _checkHandshake method is doing the following:

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

I have found this question and have the latest version of socketrocket but doesn't seem to be working?

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

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

like image 880
jodm Avatar asked Feb 21 '14 17:02

jodm


1 Answers

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.

like image 84
SudoPlz Avatar answered Nov 01 '22 20:11

SudoPlz