Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Webklex\PHPIMAP\Exceptions\RuntimeException: idle failed #682

Closed
dokicro opened this issue Oct 12, 2022 · 3 comments
Closed

[BUG] Webklex\PHPIMAP\Exceptions\RuntimeException: idle failed #682

dokicro opened this issue Oct 12, 2022 · 3 comments
Labels
needs investigation This will be tested / debugged or checked out.

Comments

@dokicro
Copy link

dokicro commented Oct 12, 2022

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:

[2022-10-11 13:30:58] production.ERROR: Webklex\PHPIMAP\Exceptions\RuntimeException: idle failed in /var/www/laravel/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:1055
Stack trace:
#0 /var/www/laravel/vendor/webklex/php-imap/src/Folder.php(402): Webklex\PHPIMAP\Connection\Protocols\ImapProtocol->idle()
#1 /var/www/laravel/app/Console/Commands/PayTicketIdleCommand.php(81): Webklex\PHPIMAP\Folder->idle()
#2 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\PayTicketIdleCommand->handle()
#3 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#4 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#5 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#6 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call()
#7 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()
#8 /var/www/laravel/vendor/symfony/console/Command/Command.php(298): Illuminate\Console\Command->execute()
#9 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
#10 /var/www/laravel/vendor/symfony/console/Application.php(1015): Illuminate\Console\Command->run()
#11 /var/www/laravel/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#12 /var/www/laravel/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#13 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\Component\Console\Application->run()
#14 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()
#15 /var/www/laravel/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#16 {main}

I am connected to Gmail business account

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 ?

Desktop / Server (please complete the following information):

  • OS: Cenots 7
  • PHP: PHP 8.1.9
  • Version "webklex/laravel-imap": "^4.0",
@dokicro dokicro added the needs investigation This will be tested / debugged or checked out. label Oct 12, 2022
@dokicro dokicro closed this as completed Oct 12, 2022
@gazben
Copy link

gazben commented Nov 14, 2022

@dokicro Did you get a chance to solve this?

We got a similar exception:

<< * 18 EXISTS
>> DONE
<< * 2 RECENT
>> DONE
<< TAG15 OK Idle completed (244.999 + 244.999 + 244.998 secs).
>> TAG16 IDLE
<< DONE BAD Error in IMAP command: Invalid command name (0.001 + 0.000 secs).
[2022-11-14 10:02:15] production.ERROR: idle failed {"exception":"[object] (Webklex\\PHPIMAP\\Exceptions\\RuntimeException(code: 0): idle failed at /var/www/html/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:1062)

@dokicro
Copy link
Author

dokicro commented Nov 14, 2022

I did but hacky way take a look at this: Webklex/laravel-imap#453 (comment)
Everything was working fine with that workaround but then Gmail started hitting me with quota limits so I had to switch to https://github.com/dacastro4/laravel-gmail and have a corn job every minute pulling the data...

@gazben
Copy link

gazben commented Nov 16, 2022

I'm using mailbox.org and I'll try out this solution: Webklex/php-imap@master...apicore-engineering:php-imap:master

In our case the problem was that after the DONE and IDLE commands the package expects the + idling or OK responses and if a new email comes in the command will fail.

Example:

>> DONE
<< * 1 RECENT
<< TAG18 OK Idle completed (0.591 + 0.590 + 0.590 secs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This will be tested / debugged or checked out.
Projects
None yet
Development

No branches or pull requests

2 participants