openswoole / docker-openswoole

Docker image for Open Swoole
https://hub.docker.com/r/openswoole/swoole
Apache License 2.0
42 stars 5 forks source link

Basic websocket connection don't work. Needs proper new example? #13

Closed danilocgsilva closed 2 years ago

danilocgsilva commented 2 years ago

Implementing an hello world websocket connection from web browser to the available examples codes always fails with a browser error:

WebSocket connection to 'ws://0.0.0.0:92/' failed: Error during WebSocket handshake: Unexpected response code: 200

Comparing the response headers from others websocket solutions, like node ws, node websocket, socket.io and even the old Swoole, I found that the problem is that there are issues with the server response that cause errors in the client. The response headers are way different from previous solutions tested. I tried to make changes to response headers. The errors changed on each tweak, and seemed that I was going to the right way, but still finisheds with WebSocket connection to 'ws://0.0.0.0:8082/' failed: Invalid frame header. Still don't know how to fix this one.

I was thinking if still there's not an proper example to deal with websocket. Or if there are a more serious issue with Swoole\Http\Response that breaks a websocket client connection.

So I would like to request an example aimed to provide a basic and stable websocket connection to a client (preferibly, a client implemented in a web browser), or some help to fix the Invalid frame header message.

Thanks in advance!