首页 > 解决方案 > TCP 连接挂断但不抛出超时异常 C# (ActiveUp.Net.Mail)

问题描述

代码永远挂起,直到关闭 tcp 调用的程序并且不抛出任何异常我已经尝试重新连接每个电子邮件获取

var client = new Imap4Client();
client.SendTimeout = 180000;
client.ReceiveTimeout = 300000;
client.ConnectSsl(mailServer, port );
client.LoginFast(EmailId, password);

........

try {
    Mailbox mails = client.SelectMailbox(mailBox);
    int Count = mails.MessageCount;

    while (Count > 0 && ControlLoop && client.IsConnected)
    {
        ... disconnect & create new TCP email login 
        FlagCollection fg = mails.Fetch.Flags(Count); // timeout not working
        ActiveUp.Net.Mail.Message msg = mails.Fetch.MessageObject(Count); // timeout not working

        IFlagCollection newfg = fg;
        mails.SetFlags(Count, newfg); // timeout not working
        
        int getuid = mails.Fetch.Uid(Count); // timeout not working
        
       Count--;
       --- ControlLoop  set true for last 6 hour data only 
        ..... save messages in DB
    }
} catch(Exception ex){ 
        .... log error
        }
    ```

标签: c#mailsystem.net

解决方案


推荐阅读