Adding scheduled tasks during onWorkerStart will cause register verification errors Register auth timeout

adding more than one hour of scheduled tasks to onWorkerStart in GatewayWorker businessworker will cause register verification errors to report pid:1 Register auth timeout (127.0.0.1). See http://wiki.workerman.net/Error4 for detail error,

find the reason for the connectToRegister method $this- > _ registerConnection- > send in the BusinessWorker class ("{"event": "worker_connect", "secret_key": ". $this- > secretKey.""}"); failed to send the message successfully,

guess the reason: the sending statement is not executed after the link is successful, and the scheduled task that is added for more than an hour blocks the _ registerConnection link ().
the solution changes $this- > _ registerConnection- > send ("{"event": "worker_connect", "secret_key": ". $this- > secretKey.""}");
to:
$this- > _ registerConnection- > onConnect = function ()

    {
        $this->_registerConnection->send("{"event":"worker_connect","secret_key":"" . $this->secretKey . ""}");
    };
Jul.30,2021

your GatewayWorker version should not be up to date. The verification of the latest version of Gateway and businessworker is done in onConnect. The latest version supports multi-register, to make GatewayWorker ultra-high availability.

finally, it is not recommended to put time-consuming tasks in businessworker, as this will block the process, and the tasks forwarded by Gateway to businessworker cannot be processed in time, resulting in message processing or sending delays.

Menu