reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.2k stars 156 forks source link

Socket Server disconnects after a few minutes of idle time #228

Closed Kreatous closed 4 years ago

Kreatous commented 4 years ago

I have a simple socket server

$loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server(sprintf('127.0.0.1:%s', $this->port), $loop); $socket->on('connection', function (React\Socket\ConnectionInterface $connection) use ($loop, $socket, $conn) { $connection->on('data', function ($data) use ($connection, $loop, $socket) { }); }, function (Exception $error) { var_dump($error); }); $loop->run();

after about a 5 minute idle time if i try to connect to it, then it connects for a second and disconnects the socket server is there any socket timeout or a way to keep it running in an infinite loop

WyriHaximus commented 4 years ago

Try setting an on error listener on the socket, that should give you an idea if there are issues on that side

Kreatous commented 4 years ago

i have added an error exception listener but still nothing no error output even php logs are not showing anything

$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server(sprintf('0.0.0.0:%s', $this->port), $loop);

$socket->on('connection', function (React\Socket\ConnectionInterface $connection) use ($loop) {
        $connection->on('data', function ($data) use ($connection, $loop) {
        }, function (Exception $error) {
            var_dump($error);
        });
    }, function (Exception $error) {
        var_dump($error);
    });

    $loop->run();
Kreatous commented 4 years ago

Thank You @WyriHaximus for your response the problem was with max_execution_time it was limited to 120 seconds so the script always stopped adding set_time_limit(0); or ini_set('max_execution_time', '0'); fixes the issue Thank you once again :)

clue commented 4 years ago

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this :+1: