I am trying to do this in php
websocket.onmessage = function(evt) {
console.log("Message Received: " + evt.data);
};
Can anyone help ?
What I have tried:
My php code:
$client->send( json_encode($info) );
$data = json_decode( $client->receive() );
$x=0;
while ($x<10) {
sleep(1);
echo $x."<br>";
echo $client->receive();
}
The result is a mix of the information I need and error;
7a6efd45-8a35-4530-a477-b25bd5b584ff0
{"success":true}
{"values":{"0":"16:59:21","3":"22,66","4":"22,66"},"type":"QuoteType","parameter":"petr4"}
{"values":{"0":"16:59:22","3":"22,77","4":"22,77"},"type":"QuoteType","parameter":"petr4"}
AND THE ERROR MESSAGE
Fatal error: Uncaught WebSocket\ConnectionException: Empty read; connection dead? Stream state: {
"crypto":{"protocol":"TLSv1.2","cipher_name":"ECDHE-RSA-AES128-GCM-SHA256","cipher_bits":128,
"cipher_version":"TLSv1.2"},"timed_out":true,"blocked":true,"eof":false,"stream_type":"tcp_socket\/ssl",
"mode":"r+","unread_bytes":0,"seekable":false} in F:\xampp-php72\...\websocket\lib\Base.php:269
Stack trace: #0 F:\xampp-php72\htdocs\testcodes\call\vendor\textalk\websocket\lib\Base.php(143):
WebSocket\Base->read(2) #1 F:\xampp-php72\htdocs\testcodes\call\vendor\textalk\websocket\lib\Base.php(135):
WebSocket\Base->receive_fragment() #2 F:\xampp-php72\htdocs\...\example.php(57):
WebSocket\Base->receive() #3 {main} thrown in F:\xampp-php72\htdocs\...\websocket\lib\Base.php on line 269