mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-08-25 08:00:35 +00:00
Merge pull request #22 from KolbeinNL/fix-lost-connection
Fix: dead connections used for commands (IMAP)
This commit is contained in:
@@ -25,7 +25,10 @@ impl bb8::ManageConnection for ImapConnectionManager {
|
||||
}
|
||||
// call this function before using the connection
|
||||
async fn is_valid(&self, conn: &mut Self::Connection) -> RustMailerResult<()> {
|
||||
match tokio::time::timeout(Duration::from_secs(5), conn.noop()).await {
|
||||
if conn.is_bad {
|
||||
return Err(raise_error!(format!("Connection marked broken"), ErrorCode::ImapCommandFailed));
|
||||
}
|
||||
match tokio::time::timeout(Duration::from_secs(5), conn.run_command_and_check_ok("NOOP")).await {
|
||||
Ok(Ok(_)) => Ok(()),
|
||||
Ok(Err(e)) => {
|
||||
error!("IMAP connection validation failed: {:?}", e);
|
||||
|
||||
@@ -16,7 +16,7 @@ use tokio_io_timeout::TimeoutStream;
|
||||
use tokio_socks::tcp::Socks5Stream;
|
||||
use tracing::error;
|
||||
|
||||
pub(crate) const TIMEOUT: Duration = Duration::from_secs(60);
|
||||
pub(crate) const TIMEOUT: Duration = Duration::from_secs(3600);
|
||||
|
||||
pub(crate) async fn establish_tcp_connection_with_timeout(
|
||||
address: SocketAddr,
|
||||
|
||||
Reference in New Issue
Block a user