S
S
Sergey Sokolov2020-05-05 16:13:07
PHP
Sergey Sokolov, 2020-05-05 16:13:07

How to send a message on a server timer in Swoole, error 9009?

It is necessary to send to all connected once every X seconds. the same message.
In the object, during initialization, I save $this->server = new \Swoole\Server(...);
Configure, hang up listeners and start the server timer:

$this->server->tick(1000, function () {
    $this->update();
});

In the update() method I send out:
foreach ($this->server->connections as $fd) {
    $this->server->push($fd, $message);
}

But the message does not go away, and errors appear in the log:
[2020-05-05 12:23:56 #21985.2]  ERROR   swServer_tcp_send (ERRNO 9009): 
    can't send data to the connections in master process


How to properly send a message not by callback from an incoming message, but by a server timer?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question