reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.

Home Page:https://reactphp.org/socket/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No support for websockets?

Henshall opened this issue · comments

Hello - I have been trying to get web sockets working with this for the last few days - specifically url's such as "wss://cerberus-xxxx.lb.slack-msgs.com/websocket/KHAM3gifDwkNzSW1epUuKursfVk...". Is this type of url supported? It seems that it does not work but also does not return any errors.

I have the following code:

$loop = Factory::create();
$connector = new Connector($loop);
$connector->connect($url)->then(function (ConnectionInterface $connection) use ($loop) {
$connection->pipe(new WritableResourceStream(STDOUT, $loop));
$connection->write('{
"type": "message",
"ts": "11111",
"user": "noone",
"text": "sample text"
}');
});
$loop->run();

Thank you!

Reactphp Sockets are RAW Socket connections, Websockets is a protocol which needs an implementation like Ratchet or Thruway.

There is a blog post by @WyriHaximus about this topic https://blog.wyrihaximus.net/2015/03/reactphp-sockets/

As mentioned, react/socket implements raw sockets while WebSockets is a network protocol on top of TCP/IP sockets and uses HTTP as initial handshake. You should check out Pawl and WebSocketMiddleware for websocket client and server respectively. Or Ratchet for a higher level websocket server.

They all build on top of ReactPHP to implement websockets.

I'll assume this is resolved and will close this for now, please feel free to report back otherwise 👍