-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. #921
Comments
That sounds like an error you would get in SmtpClient.Connect(), not SmtpClient.Send(). Are you sure you're getting that in Send()? Also, that's an error that gets thrown from Socket.Connect() (or, in MailKit's case, Socket.Begin/EndConnect() since it uses the async API). There have been a number of reports like this but every person who has reported this has eventually discovered that they had networking problems and/or had Avast! antivirus installed which has a firewall. Do you have Avast! installed? Any other virus scanner that has a firewall? |
it seems to be happening in the Send. I am able to step over the Connect method without problem. After stepping over Send it hangs for like a minute or 2 before dropping into my catch. I discovered the ProtocolLogger when searching through other issues. Here's my results:
|
regarding antivirus, i have Symantec Endpoint Protection. i don't see anything blocked in there. also, when using the System.Net.Mail SmtpClient, that doesn't get blocked and works fine.. would it be safe to assume MailKit SmtpClient wouldn't get blocked as well? |
n/m, this isn't a firewall issue based on your log or you wouldn't be able to connect at all. |
Can you try using MailKit 2.2.0? |
or... better yet, just try this: ...
client.Connect (...);
client.Capabilities &= ~SmtpCapabilities.Chunking;
client.Capabilities &= ~SmtpCapabilities.Binary;
client.Send (...); |
2.20 worked AND the following worked on Mailkit 2.3.1.6 as well!
much mahalo! |
Curious what the following code snippet produces for you: using (var memory = new MemoryStream ()) {
var options = FormatOptions.Default.Clone ();
options.NewLineFormat = NewLineFormat.Dos;
options.EnsureNewLine = true;
message.WriteTo (options, memory);
Console.WriteLine ("memory.Length = {0}", memory.Length);
} |
|
wtf, seems like a bug in Exchange not properly counting the bytes it has received?? Does the stream end with a newline sequence? using (var memory = new MemoryStream ()) {
var options = FormatOptions.Default.Clone ();
options.NewLineFormat = NewLineFormat.Dos;
options.EnsureNewLine = true;
message.WriteTo (options, memory);
var buffer = memory.ToArray ();
var eoln = buffer[buffer.Length - 2] == '\r' && buffer[buffer.Length - 1] == '\n';
Console.WriteLine ("buffer length = {0}, ends with newline = {1}", buffer.Length, eoln);
} |
i think we're on Exchange Server 2016
|
In case it's not obvious what I'm lookin at, I'm verifying that the What appears to be happening is that MailKit's SmtpClient is completing the |
You've got MimeKit 2.3.1, right? I'm pretty sure MailKit 2.3.1.6 pulls in MimeKit 2.3.1 so you should have it, but just to verify... (MimeKit 2.3.1 has an essential fix for BDAT to work properly). |
Anyway, time for me to go to bed, but I'll think about this more tomorrow. |
I just brought in MailKit 2.3.1.6 via NuGet. If I check Packages > MailKit > MimeKit it states (2.3.1). Thanks for the quick replies, and for the awesome library! Good night! Let me know if you want me to try anything else. Thanks again! |
This should solve the issue by using the IMHO, this is actually a bug in Exchange, but this fix is all I can do. |
Thanks! |
@jstedfast Since BDAT was taken out for this potential case, is it possible to add the ability to control / opt-in to the BDAT behavior (if supported) on a SmtpClient session? |
Yes, that'll work. Thanks! |
This worked for me thank you very much
|
I get the following error message when trying to send a simple message:
I have a simple console app that's doing this:
It hangs when trying to call Send and comes back with the error message above.
If I use the regulat .NET SmtpClient I have no problems running the following and getting an email:
So I don't believe I have a firewall or port issue. What am I missing?
Trying this from a console app with .NET Core 3.0. Also tried from a .NET Standard 2.0 class library project. Using MailKit 2.3.1.6.
The text was updated successfully, but these errors were encountered: