从另一个PHP脚本连接到PHP套接字服务器

I'm trying to use the websocket in php and I found this script https://code.google.com/archive/p/php-websocket-server/ I would like to send the notifications to clients connected via a cron that makes the query to the database and retrieves the data, to do that I need to connect to the socket server from php script, i tried doing this:

  if($socket = stream_socket_client("tcp://"._SOCKET_SERVER_.":"._SOCKET_PORT_, $errno, $errstr, 30,STREAM_CLIENT_CONNECT)) {


   foreach($query_result as $notification) {
     $data = json_encode($notification);
     fwrite($socket,$data);
   }


  fclose($socket);

  }

the stream_socket_client () function does not return errors and so the server is connected, but i can't send messages because as soon as i connect, the server is disconnected and fwrite can't write nothing. Practically does not maintain the connection or the server kick me off for some reason, someone has idea why?