The isUidOnline ($uid) of gatewayworker in workerman is not online.

question 1: worker, the device on my side has successfully logged in and bound uid,. When receiving heartbeat instructions, I made a judgment on whether uid is online, but when the device successfully logged in for the first time and sent a heartbeat, Gateway::isUidOnline ($uid) always judged that it was not online. When the device logged back in and sent the heartbeat again, Gateway::isUidOnline ($uid) would judge that it was online, and I printed $client_idarr,. That is, the clientid; bound by uid
Gateway::bindUid ($client_id,$uid);
$client_idarr = Gateway::getClientIdByUid ($uid);
found that this variable has a value, then the device should have successfully bound client_id, and printed uid, found that uid is also normal, but Gateway::isUidOnline ($uid) is still not online. Another thing is that this is not the case for all devices. Please also give us advice

.

question 2:
$gateway- > pingInterval = 55;
$gateway- > pingNotResponseLimit = 2;
and
$gateway- > pingInterval = 110;
$gateway- > pingNotResponseLimit = 1; what"s the difference between
?

Jun.25,2021

question 1:

    public static function isUidOnline($uid)
    {
        return (int)static::getClientIdByUid($uid);
    }

isUidOnline is implemented based on getClientIdByUid, so if Gateway::getClientIdByUid ($uid); has a value, then isUidOnline will definitely return a non-zero value, and print the return values of isUidOnline and getClientIdByUid at the same time.

question 2:
according to the manual

$gateway->pingInterval = 55;
$gateway->pingNotResponseLimit = 2;

means that the server sends a heartbeat to the client every 55 seconds (if the pingData has a value). If the client does not send any data within 55 seconds, it means that the client has been disconnected, and the server closes the connection

.
$gateway->pingInterval = 110;
$gateway->pingNotResponseLimit = 1;

sends a heartbeat to the client in 110 seconds. Similarly, if no data is sent within 110 seconds, the client has been disconnected and the server closes the connection

.

manual: http://doc2.workerman.net/hea.


@ walkor
about question 2, I have a question. Please guide:
according to the source code and test, assuming that in the case of pingNotResponseLimit > 0, for the two ways of writing, I understand:
(1) [this should be no problem] both represent: if the client connects pingInterval * pingNotResponseLimit = 110s without any request, the server thinks that the corresponding client has gone offline. The server actively closes the connection and triggers the onClose callback.
(2) [this is different from my understanding] the difference between the two writing methods is that both methods represent sending a heartbeat every pingInterval / 2 seconds, and the heartbeat detection frequency is: pingNotResponseLimit * 2, that is, the heartbeat detection interval is different from the heartbeat detection frequency.


(1) Yes
(2) A heartbeat is sent every pingInterval time, not pingInterval/2 seconds. However, the server will check once in pingInterval/2 seconds whether a client has not sent any data for more than pingInterval * pingNotResponseLimit seconds. If it is considered that the client has dropped the line, close the corresponding connection.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31947-2bd9b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31947-2bd9b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?