Ratchet
Ratchet copied to clipboard
websocat gives errors when closing connection and received message is garbled.
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
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.
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.
What's does your websocket configuration look like ?