I'm doing my first test, trying to use a phpwebsocket.
I set its handshake Sec-WebSocket-Accept header value to the following:
$accept=base64_encode(SHA1($key."258EAFA5-E914-47DA-95CA-C5AB0DC85B11", true));
/* $key has $buffer value */
So I run the websocket php file (that creates a connection), as all okay.
So I run my test html that contains a script that try to connect to the phpwebsocket that I'm using, and in browser console I get this error:
fc.js:43 WebSocket connection to 'ws://localhost:8000/PetStack/inc/server.php' failed: Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value
But I found this Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value with PHP, which is solved by defining buffer limit, would be my problem that?
I don't understand how to define the buffer limit, but case it's my problem, please explain me.
It wasn't me that made this phpwebsocket, I'm just using it.
Well, this is the line of variable $upgrade in a phpwebsocket file, that sets some headers.
"HTTP/1.1 101 Web Socket Protocol Handshake\r\n".
"Upgrade: WebSocket\r\n".
"Connection: Upgrade\r\n".
"WebSocket-Origin:{$origin}\r\n".
"Sec-WebSocket-Accept:".$accept."\r\n\r\n".
"WebSocket-Location: ws://{$host}{$resource}\r\n\r\n".
chr(0);
$key;$key=substr(substr((string)$buffer,strpos ((string)$buffer,'Sec-WebSocket-Key:')),strpos((string)$buffer,' ')+1,strpos((string)$buffer,'=')+1);- but I still get the same error. :( - user5489593