walkor / phpsocket.io

A server side alternative implementation of socket.io in PHP based on workerman.
2.3k stars 508 forks source link

I have this issue where I switch to daemon mode and get no communications after a connection to the server is made #269

Closed binemmanuel closed 2 years ago

binemmanuel commented 2 years ago

On daemon mode connections to the server is successfully made but no communications are made though when I check the status I notice that requests are made but nothing gets to the app.

I've got PHP 8.0.13 with 10.3.32-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.0 and I'm trying to connect from a mobile built with Flutter.

Screenshot 2021-12-19 at 09 14 50
walkor commented 2 years ago

Do you mean it works fine when you switch to non daemon mode?

binemmanuel commented 2 years ago

It doesn't work at all on daemon mode though everything looks fine without daemon and I've been wondering if it has a thing to do with the version I'm using on the client.

walkor commented 2 years ago

Do not initialize the database connection before the Worker::runAll() runs. Please initialize the database connection in workerStart like this.

$io = new SocketIO(9120);
$io->on('workerStart', function()use($io) {
    // Init your database connection here.
});
binemmanuel commented 2 years ago

Instantiating the database connection on workerStart fixed my problem, I appreciate the help.