Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocat gives errors when closing connection and received message is garbled. #1048

Open
geoidesic opened this issue Jan 8, 2024 · 3 comments

Comments

@geoidesic
Copy link

geoidesic commented Jan 8, 2024

Hi,

I'm using Caddy for Letsencrypt.

I have managed to get the basic Ratchet examples to connect to the letsencrypt certs and was able to do the TLS handshake correctly via openssl. But whenever I try to use websocat I get errors. Also the message received by the server is gobbledygook.

echo "YourWebSocketMessage" | websocat --text wss://uat.sport.co.uk:5502

This works... it sends a message and the server fires the onMessage handler.. but if I do var_dump($msg) the output is gobbledygook ascii nonsense. And either way, if I provide a response or close the connection, the client shows errors.

    public function onMessage(ConnectionInterface $from, $msg) {
        var_dump($msg);  //<-- outputs (string) <ascii gobbledygook>
        $response = "Server Response: Your message has been received.";
        $from->send($response, 'websocket::TYPE_TEXT');  //<--- causes error: websocat: WebSocketError: WebSocket SSL error: record overflow
        $from->close(1000, 'Server initiated close');    //<--- causes error: websocat: WebSocketError: WebSocket SSL error: connection closed via error  
    }

Incidentally, the reason I'm using websocat is because the examples from the Ratchet website, where you just bung some code into the javascript console, didn't work for me... it won't connect, gives error:

WebSocket connection to 'wss://uat.sporth.co.uk:5502/' failed: 
(anonymous) @ VM65:1
@quakemmo
Copy link

quakemmo commented Jan 9, 2024

Using Ratchet with SSL directly doesn't seem stable enough. I recommend you put an Apache (or something) reverse proxy in front of it for SSL, which works reasonably well. Then just use vanilla-HTTP Ratchet.

@geoidesic
Copy link
Author

Using Ratchet with SSL directly doesn't seem stable enough. I recommend you put an Apache (or something) reverse proxy in front of it for SSL, which works reasonably well. Then just use vanilla-HTTP Ratchet.

Tried that. Couldn’t get it to work at all. It was easy enough with NodeJS Express but couldn’t get it working with Ratchet.

@newmediacrew
Copy link

What's does your websocket configuration look like ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants