Skip to content

SelectMailbox function may hang #48

@Haifovchanin

Description

@Haifovchanin

I am writing an application that processes user emails. O start the application connects to Gmail and then once per minute checks for new emails.
After approximately 12 - 20 hours the application stops processing new emails. Using logs I found, that line Mailbox mailBox = _gmailClient.SelectMailbox("inbox"); is the last one executed in this code.
Because the code is not in try / catch block I know that this is not a crash.

Please, advise.
Thank you.

Below is a part of code that retrieves new emails, where _gmailClient is Imap4Client() connected to Gmail using ConnectSsl("imap.gmail.com", 993)

OutputLog($"RetrieveAndProcessNewEmails - In locked code.");
if (!_gmailClient.IsConnected)
{
    OutputLog($"IMap client is not connected. Reconnecting...");
    if (!(ConnectIMap4Client("imap.gmail.com", 993, true) && LoginIMap4Client("email", "pass")))
        return;
}
OutputLog($"RetrieveAndProcessNewEmails - connected to GMail");
Mailbox mailBox = _gmailClient.SelectMailbox("inbox");
if (mailBox == null)
{
    OutputLog("Mailbox is null! Processing incoming emails is disabled");
    return;
}
OutputLog($"RetrieveAndProcessNewEmails - mailbox found: {MailBox2String(mailBox)}");
messages = mailBox.SearchParse("UNSEEN");
if (messages.Count == 0)
{
    OutputLog($"Currently there is no new messages...");
    return;
}
else
    OutputLog($"New {messages.Count} found.");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions