Skip to content
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

IOException #80

Open
elvinyang opened this issue May 30, 2012 · 11 comments
Open

IOException #80

elvinyang opened this issue May 30, 2012 · 11 comments

Comments

@elvinyang
Copy link

Code:
var imap = new ImapClient("imap.gmail.com", "[email protected]", "pwd", AE.Net.Mail.ImapClient.AuthMethods.Login, 993, true);
imap.NewMessage += (sender, e) =>
{
var newMsg = imap.GetMessage(e.MessageCount - 1);
Console.WriteLine("Total email: {0}, current subject {1}.", e.MessageCount, newMsg.Subject);
};
After the NewMessage event is triggered, it'll later get an exception:

System.IO.IOException was unhandled
Message=Unable to read data from the transport connection: 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.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Stream.ReadByte()
at AE.Net.Mail.TextClient.GetResponse() in C:\Users\elviny\Desktop\andyedinborough-aenetmail-7ed7bf1\TextClient.cs:line 106
at AE.Net.Mail.ImapClient.<>c__DisplayClass4.b__3(Object _) in C:\Users\elviny\Desktop\andyedinborough-aenetmail-7ed7bf1\ImapClient.cs:line 135
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
InnerException: System.Net.Sockets.SocketException
Message=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
Source=System
ErrorCode=10060
NativeErrorCode=10060
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:

Inner exception: {"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"}

Stack:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

@NadavK
Copy link

NadavK commented Jun 25, 2012

I also have this issue!
This renders IDLE useless (after the first mail).
Any suggestions?

@smiley22
Copy link

smiley22 commented Aug 2, 2012

Hello I am having the same problem. It seems commenting out stream.ReadTimeout = 10000 in Utilities.cs fixes the problem. I wouldn't know why it times out in the first place though, 10000ms seems like a reasonable timeout value...

@smiley22
Copy link

smiley22 commented Aug 3, 2012

I believe the problem is that ReadToEnd is being called on the network stream (for instance in the MailMessage Load method), which is then setting the read timeout value to 10000ms. The timeout would then be triggered when the client goes into IDLE mode waiting on the socket to receive notifications from the server.

What's the purpose of setting a ReadTimeout value in the first place in the ReadToEnd and ReadLine methods?

@brian32768
Copy link

I tried smiley22's fix -- I commented out the lines that set the timeout to 10000, it worked for a few minutes.
Then I tried setting it to -1 instead of 10000 and it seems to be working now.

@zlajson
Copy link

zlajson commented Aug 16, 2012

I am also having this issue. If I try with fix mentioned by smiley22 I get:

Exception of type 'System.OutOfMemoryException' was thrown.

Utilities.cs line 27. mem.WriteByte(b);

@anbinhtrong
Copy link

I have a problem as zlaja

@nambtt
Copy link

nambtt commented Nov 8, 2012

My code:
var fromAddress = new MailAddress(from);
var toAddress = new MailAddress(to);
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
Timeout = -1,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, frompw)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}

This code run with no problem on my home machine but when I run it on another machine which have a connection to proxy server, it's not work. I'm not sure the problem is due to proxy or not but it may be a clue.

Anyone get the same situation?

@JustDerb
Copy link

+1
Having the same problem with IDLE support....

Then I tried setting it to -1 instead of 10000 and it seems to be working now.

That didn't work for me :(

@benfoster
Copy link

+1
Also experiencing this issue with Gmail Mailbox.

@StephanosSteer
Copy link

Found this issue (so far, only just started) in Hotmail changed timeout to -1 as above and that worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

11 participants