Dec 29, 2021
0
Level 10
WebSocket Issue
I'm trying to send data using WebSocket using this package https://github.com/ratchetphp/Pawl
My goal is to send data to my server ws://localhost:6000
Then this is the script:
\Ratchet\Client\connect($url)->then(function ($conn) {
$data = json_encode(['message'=>'Hello']);
$conn->send($data);
$conn->close();
});
This works with perfect and successfully sends the payload. But when i'm trying to call this script in Tinker it's not working.
But when i tried to dd() the script it will work.
dd(\Ratchet\Client\connect($url)->then(function ($conn) {
$data = json_encode(['message'=>'Hello']);
$conn->send($data);
$conn->close();
}));
Any ideas to fix this? Thanks in advance.
Please or to participate in this conversation.