React PHP - 1006(Underlying Connection closed)

Asked

Viewed 17 times

0

Periodically - and this time is not absolute, between 3~5 minutes, the connection I make via websocket (with the Ratchet library), returns me the following error(I capture in connection closure):

code(1006) reason(Underlying closed Connection)

From what I read, this error happens on my side (as client), it does not seem to be something that the server I am connecting to, has provoked.

I don’t own ping/pong boards, I don’t know how to implement them in my case, but I don’t believe this is the problem, although I consider..

Code(sample):

$loop      = \React\EventLoop\Factory::create();
$connector = new \Ratchet\Client\Connector($loop);

    $connector("wss://xx.yy/ws")->then(function ($conn) use ($loop, $connector) {

        $send = array(
            "method" => "xxx"
        );

        $conn->send(json_encode($send));

        $conn->on('message', function ($msg) use ($connector, $conn, $send) {

            $arr = json_decode($msg, true);

            if (isset($arr["id"])) {
            faca_algo($arr["s"], $arr["b"], $arr["a"], time(), $arr);
            }

        });

        $conn->on('close', function ($code = null, $reason = null) use ($loop, $connector) {
            $GLOBALS["Functions"]->SaveLog("Conexão Websocket foi fechada, codigo(" . $code . ") razão(" . $reason . ")", "LOG_WARN");
        });

    });

Important: this connection receives thousands of requests per second(around 1~2k), I have no CPU or Memory problem, this process does not lock, the loop is not terminated, only the connection drops with this 1006 error..

Using Centos8, Nginx and Apache.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.