Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Apr 18, 2020 · 4 comments
Closed

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

ghost opened this issue Apr 18, 2020 · 4 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 18, 2020

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
Copy link
Member

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

@ghost
Copy link
Author

ghost commented Apr 18, 2020

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();

@ghost
Copy link
Author

ghost commented Apr 19, 2020

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 clue added the question label Apr 21, 2020
@clue
Copy link
Member

clue commented Apr 21, 2020

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 👍

@clue clue closed this as completed Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants