ConnectSsl方法抛出System.IO.IOException。远程主机强行关闭了现有连接

时间:2019-02-26 23:03:56

标签: c# .net tcpclient ioexception socketexception

我有每天检查gmail文件夹中是否有新电子邮件的测试。这已经工作了一年多,最近在调用Client.ConnectSsl(mailServer,port)时突然开始失败。我正在使用Assembly ActiveUp.Net.Imap4,版本= 5.0.3454.364

private Imap4Client client;

        public MailRepository(string mailServer, int port, bool ssl, string login, string password)
        {
            if (ssl)
                Client.ConnectSsl(mailServer, port);
            else
                Client.Connect(mailServer, port);
            Client.Login(login, password);
        }

Client.ConnectSsl(mailServer,port); 'Client.ConnectSsl(mailServer,port)'引发了'System.IO.IOException'类型的异常     数据:{System.Collections.ListDictionaryInternal}     H结果:-2146232800     帮助链接:null     InnerException:{“现有连接被远程主机强行关闭”}     消息:“无法从传输连接读取数据:远程主机强行关闭了现有连接。”     资料来源:“系统”     StackTrace:“位于System.Net.Security.SslState.ValidateCreateContext(布尔值isServer,字符串targetHost,启用了SslProtocols的SslProtocols,X509Certificate serverCertificate,X509CertificateCollection clientCertificates,布尔值remoteCertRequired,布尔值checkCertRevocationStatus,布尔值checkCertSingle.Security.System.Net)。 .AuthenticateAsClient(String targetHost,X509CertificateCollection clientCertificates,SslProtocols enabledSslProtocols,Boolean checkCertificateRevocation)\ r \ n在ActiveUp.Net.Mail.Imap4Client.DoSslHandShake(SslHandShake sslHandShake)\ r \ n在ActiveMap(Net.Mail.Mail。 ,Int32端口,位于ActiveUp.Net.Mail.Imap4Client.ConnectSsl的SslHandShake sslHandShake)\ r \ n(字符串主机,Int32端口)“     TargetSite:{Void ValidateCreateContext(Boolean,System.String,System.Security.Authentication.SslProtocols,System.Security.Cryptography.X509Certificates.X509Certificate,System.Security.Cryptography.X509Certificates.X509CertificateCollection,Boolean,Boolean,Boolean)}

建议进一步研究,以查看防火墙是否阻止了它,不是。寻找选择。谢谢

0 个答案:

没有答案