seryal / sywebsocket

WebSocket Server and Client
https://github.com/seryal/sywebsocket
19 stars 4 forks source link

Error during WebSocket handshake: net::ERR_INVALID_HTTP_RESPONSE #1

Closed mdmmdm closed 3 years ago

mdmmdm commented 3 years ago

Hi When a client connects to a server on lazarus, in the OnClientConected procedure, I immediately send a message to the client, the client then immediately crashes with an error WebSocket connection to 'ws://localhost:8080/' failed: Error during WebSocket handshake: net :: ERR_INVALID_HTTP_RESPONSE

But, if I do not immediately send a message when the client connects, but send it by pressing a button, everything is fine

seryal commented 3 years ago

O! Thanks. Yes it's bug. I will fix it.

Because OnClientConected event occurs when there is TCP connection and not after a handshake. And trying to send a message immediately you will get error.

seryal commented 3 years ago

I'm in work travel now. I plan to fix this after 03 october.

mdmmdm commented 3 years ago

Thanks.