Webklex / laravel-imap

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.
https://www.php-imap.com
MIT License
627 stars 179 forks source link

1420C0CF:SSL routines:ssl_write_internal:protocol is shutdown error #397

Closed robtesch closed 3 years ago

robtesch commented 3 years ago

Hi all,

This is very likely to be NOT a bug with this package, but rather some issue with my own setup or the setup of the imap server of our client, but I was wondering if anyone has come accross this before and could provide any suggestions on which way to go?

I've tried a bit of basic googling but nothing seems to make much sense to me.

ErrorException {#4936
  #message: """
    fwrite(): SSL operation failed with code 1. OpenSSL Error messages:\n
    error:1420C0CF:SSL routines:ssl_write_internal:protocol is shutdown
    """
  #code: 0
  #file: "/home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php"
  #line: 307
  #severity: E_WARNING
  trace: {
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:307 { …}
    Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() {}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:307 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:322 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php:979 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Query/Query.php:187 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/webklex/php-imap/src/Query/Query.php:339 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/app/Services/ImapService.php:276 {
      App\Services\ImapService->getMessages(Folder $folder, array $dateRange, Client $client): array^
      ›                       ->limit($limit, $page)
      ›                       ->get();
      › dump_if_can(['message_page' => $messagePage], $dumpMode);
    }
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/app/Services/ImapService.php:112 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/app/Jobs/IngestAgent.php:98 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/Util.php:40 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/Container.php:610 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:128 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:132 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php:67 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/app/Console/Commands/App/ForceIngestCompanyAgents.php:54 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/Util.php:40 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Container/Container.php:610 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/symfony/console/Command/Command.php:256 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Console/Command.php:121 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/symfony/console/Application.php:971 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/symfony/console/Application.php:290 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/symfony/console/Application.php:166 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Console/Application.php:92 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129 { …}
    /home/forge/my-cool-laravel-app.com/releases/20210316094131/artisan:37 { …}
  }
}

The relevant call from ImapService is like this:

$messagePage = $folder->query(config('imap.null_charset') ? null : 'UTF-8')
                                          ->whereSince($dateRange['start'])
                                          ->whereBefore($dateRange['end'])
                                          ->setFetchFlags(false)
                                          ->setFetchBody(false)
                                          ->leaveUnread()
                                          ->limit($limit, $page)
                                          ->get();
Webklex commented 3 years ago

Hi @robtesch , sorry for the late response. Do you have access to the "mail server" logs?

Best regards,

robtesch commented 3 years ago

Unfortunately not. I have recently changed our whole IMAP setup to use "overview" method instead of complex queries like above, and so far things seem to be a bit better. I will let you know if this issue resurfaces.

Webklex commented 3 years ago

Wait, so this isn't a "startup" error, but rather an error which occurs "randomly"? That's odd...

robtesch commented 3 years ago

Well, we have a lot of customers, and only a small percentage of those use IMAP as their email provider, and only a small percentage of those were facing this issue. The main one who we noticed this issue with is no longer a customer (because we simply could not connect to their server anymore... We used to be able to), so we are not entirely sure if the issue remains or not.

robtesch commented 3 years ago

But, to be clear, I wouldn't consider it a "startup" issue, since we were able to successfully do $client->connect() first without any errors.

Webklex commented 3 years ago

I'm sorry I don't have a definit answer.. But could it be a general connection issue (routing between the servers) or a rate limit of some sort which simply "kills" the connection?

Have a great weekend,

robtesch commented 3 years ago

I will report back if I have anything new. Thanks for taking the time to look at this.

On Sat, 19 Jun 2021, 16:38 Webklex, @.***> wrote:

I'm sorry I don't have a definit answer.. But could it be a general connection issue (routing between the servers) or a rate limit of some sort which simply "kills" the connection?

Have a great weekend,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Webklex/laravel-imap/issues/397#issuecomment-864421859, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHH7VGJ4QHDOOLBIBHCI2NTTTS2YXANCNFSM4ZIL3YUA .

Webklex commented 3 years ago

Hi @robtesch , I'm closing this issue as of now. Please head over to webklex/php-imap and create a new issue if the problem persists.

Best regards,