danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.74k stars 617 forks source link

Madeline Proto getSelf() #1473

Closed NuraliSahatow closed 4 months ago

NuraliSahatow commented 5 months ago

How i can catch errors when getSelf() method cannot successfully complete or null. For example i have code

for ($i = 0; $i < $numRows; $i++) {
    $row = $result->fetch_assoc();

    // Get user information from the session
    $utoken = $row['utoken'];
    $session_file = $row['session_name'];
    $MadelineProto = new \danog\MadelineProto\API($session_file,$settings);

    try {
        $MadelineProto->start();
        // Ваш код, который вызывает updates.getDifference
        $accountInfo = $MadelineProto->getSelf();
        echo "Успех!";
    } catch (\danog\MadelineProto\PTSException $e) {
        if ($e->getMessage() == 'PERSISTENT_TIMESTAMP_EMPTY') {
            // Обработка ошибки PERSISTENT_TIMESTAMP_EMPTY
            echo $i;
            echo "Ошибка: PERSISTENT_TIMESTAMP_EMPTY";
        }
    } catch (\Exception $e) {
        // Обработка других исключений
        echo "Общая ошибка: " . $e->getMessage();
    }
}

In this code i get from my database all accaounts and check ony by one if session active. when i try print_r($account_info), code printed only info about first account(session working), but in second account(session not active, i deleted session from telegram)

danog commented 5 months ago

What do your logs say? Also, updates.getDifference should not be used to fetch updates, use the event handler, instead.

NuraliSahatow commented 5 months ago

Session, tytyper288336280273: Can't garbage collect incoming message resPQ in DC 4, not handled yet!

Log said

danog commented 5 months ago

I need the entire logfile for the session that is causing issues pls

danog commented 4 months ago

Closing for inactivity, please send the MadelineProto.log file if you still have the issue.