Can't reach the socket in PHP. What could be the problem?

Good day!
Trying to deal with sockets in PHP. The server script is run through CLI. The socket is created and waits, but the client part can not get through to him. Take hosting on Yandex cloud.
Tell me, what's the problem?

The server scripts (run via CLI)

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);

define('ADDR', '');
define('PORT', 889);

if (socket_bind($socket, ADDR, PORT)) {
 echo "Bind OK\n";

if (socket_listen($socket, 10)) {
 echo "Listen OK\n";

echo "Start server!\n";

while(true) {
 $accept = socket_accept($socket);
 if ($accept) {
 echo 'There are connection! Exit.\n';

Client script
$(document).ready(function() {
 // let socket = new WebSocket("ws://");
 let socket = new WebSocket("ws://");
 socket.onopen = function() {
 message('Connection established');

 socket.onclose = function() {
 message('Link is buried');

 socket.onerror = function(error) {

 socket.onmessage = function(event) {

function message(text) {
 $('#chat-result').append('<div>' + text + '</div>');

Tried through Telnet:
telnet 889
Reach out. But via browser does not work(

Question decided!
The problem was that from the same host knocked.
Now everything is OK.
April 3rd 20 at 17:34
1 answer
April 3rd 20 at 17:36
Socket and Websocket are different sockets! The fact that you implemented on the backend is to work with the so-called unix sockets and they are irrelevant to Websockets do not have.

The websocket is an enhanced http Protocol.
The websocket server must implement the handshake (hand snack), similar to how the ssh Protocol is used when the keys of authentication.

Your entry websocket, I advise you to take Libu ready to blaze and sockets implementation.
5df16b6dc9c29539960131.jpeg - rickey_Strosin77 commented on April 3rd 20 at 17:39
@rickey_Strosin77, this does not negate the difference and to be quite convincing rfc - trinity.Hayes commented on April 3rd 20 at 17:42

Find more questions by tags PHP