Closed dokicro closed 1 year ago
I played with debug mode and here is the output:
<< TAG3 OK [READ-WRITE] INBOX selected. (Success)
>> TAG4 IDLE
<< + idling
<< * 1 EXPUNGE
>> DONE
<< * 1 EXISTS
>> TAG5 IDLE
<< TAG4 OK IDLE terminated (Success)
>> DONE
<< + idling
>> TAG6 IDLE
<< TAG5 OK IDLE terminated (Success)
Webklex\PHPIMAP\Exceptions\RuntimeException
idle failed
at vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:1055
1051▕ */
1052▕ public function idle() {
1053▕ $this->sendRequest("IDLE");
1054▕ if (!$this->assumedNextLine('+ ')) {
➜ 1055▕ throw new RuntimeException('idle failed');
1056▕ }
1057▕ }
1058▕
1059▕ /**
+1 vendor frames
2 app/Console/Commands/InfoTicketIdleCommand.php:81
Webklex\PHPIMAP\Folder::idle()
+13 vendor frames
16 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
>> TAG7 LOGOUT
<< + idling
<< TAG6 BAD Could not parse command
The problem could be that TAG5 came after TAG6 ?
I've had the same issue happen to me; it seems I can replicate it by sending an email to the account I'm listening to (a gmail account), and then deleting the email that comes in (via the gMail interface). The exception is then thrown. This wouldn't be too much of an issue, except for the fact that the artisan command keeps running, and then it doesn't monitor any new incoming emails :\
I solve that by changing Folder.php
idle method to just throw the exception so from this:
catch (Exceptions\RuntimeException $e) {
if(strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) {
$connection->done();
$connection->idle();
continue;
}
if(strpos($e->getMessage(), "connection closed") === false) {
throw $e;
}
$this->client->reconnect();
$this->client->openFolder($this->path, true);
$connection = $this->client->getConnection();
$connection->idle();
}
To this:
catch (Exceptions\RuntimeException $e) {
throw $e;
}
And in my idle command I have this:
try {
$folder->idle(function ($message) {
$this->onNewMessage($message);
});
} catch (\Exception $e) {
return;
}
This way artisan command is not stuck but it restarts itself (I set my restart interval to 1s)
As an additional check, I have a command that runs every 10 minutes and checks if there are some unread emails and imports them...
Its quite hacky way but it works...
Having this issues as well on Gmail Workspace accounts. Also tested on generic IMAP server setup via Mail-in-a-Box with same issue. Hopefully this simple repro will help.
Easy Repro:
<< TAG3 OK [READ-WRITE] INBOX selected. (Success)
>> TAG4 IDLE
<< + idling
*** Message from INBOX Deleted Here from a email client***
<< * 3 EXPUNGE
>> DONE
<< * 2 EXISTS
>> DONE
<< TAG4 OK IDLE terminated (Success)
>> TAG5 IDLE
<< * BAD [CLIENTBUG] Invalid tag
>> TAG6 LOGOUT
<< + idling
<< TAG5 BAD Could not parse command
*** IDLE is no longer working at this point, even a client->reconnect() will not help ***
Hi @dokicro @danives @edh72 , many thanks for the report and all the examples / outputs.
Are you using the latest webklex/php-imap
release v4.1.0 ? If not, please update and try again.
This repository (webklex/laravel-imap
) depends on webklex/php-imap
, Please report any future issues over there :)
https://github.com/webklex/php-imap/issues
However, I can see how deleting / moving an email while it's being processed might cause issues. But what you are describing sounds like you receive a new mail, it gets parsed, you delete this email through some other client and idle stops working as expected?
If you look at your config file, are you using IMAP::ST_UID
or IMAP::ST_MSGN
as sequence
? If you are using ST_MSGN
, please switch to IMAP::ST_UID
and try again.
Best regards & happy coding,
Hey; yes I'm using the 4.1.0 of php-imap, and can see in my imap.php
file that the sequence is set to use \Webklex\PHPIMAP\IMAP::ST_UID
.
Still no luck in being able to resolve the issue myself, namely as I'm also encountering the an issue thats been reported on the main repo as well: https://github.com/Webklex/php-imap/issues/334
I too am using it on a Gmail workspace account (or was using it on it), so maybe it's something with gmail?
Bump. Experiencing the same "Idle Failed"
Even though it was working fine till a couple of days ago.
having same issue . . .
Same issue with me and I do not delete anything. Just sent the first email: Works send the second email: idle failed.
Hi @dokicro @danives @edh72 , many thanks for the report and all the examples / outputs.
Are you using the latest
webklex/php-imap
release v4.1.0 ? If not, please update and try again. This repository (webklex/laravel-imap
) depends onwebklex/php-imap
, Please report any future issues over there :)
under php-imap it says, that we should try to reproduce the problem with version 5.1. But I am currently using laravel-imap and then 5.1 is not available. I also tried to switch to php-imap, but then idle did not register the new mail.
For anyone experiencing the same issue, please update to the latest release >= v5.3. If the issue persists, please head over to https://github.com/Webklex/php-imap/issues/new?assignees=&labels=&projects=&template=bug_report.md and create a new report.
Best regards & happy coding,
Describe the bug After 10-30minutes of running custom idle command per instructions (https://www.php-imap.com/frameworks/laravel/commands) I get the following error:
I am connected to Gmail business account
Desktop / Server (please complete the following information):