aenetmail
aenetmail copied to clipboard
IDLE command does not work properly (unstable)
I have instantiated ImapClient class successfully. I hooked up the two events of NewMessage and MessageDeleted to be notified when a message arrives or deleted. The code sample below implies it:
_imapClient.NewMessage += (sender, e) =>
{
var msg = _imapClient.GetMessage(e.MessageCount - 1);
Trace.TraceInformation(msg.Uid);
};
_imapClient.MessageDeleted += (sender, e) =>
{
var msg = _imapClient.GetMessage(e.MessageCount - 1);
Trace.TraceInformation(msg.Uid);
};
There is only one incident or two that the application is notified (even that's by chance). In rest of cases, you never receive any notifications.
So, we found a fix for this, but I'd like to run it by someone - basically, the issue is that the "Read" command was timing out before it ever could read idle updates. But, it looked like this was by design, so I'm curious if I messed anything else up by adding an optional read timeout:
internal static string ReadLine(this Stream stream, ref int maxLength, Encoding encoding, char? termChar, int readTimeout = 10000) { if (stream.CanTimeout && readTimeout > 0) stream.ReadTimeout = readTimeout;
Correction, did this (Utilities.cs:92):
internal static string ReadLine(this Stream stream, ref int maxLength, Encoding encoding, char? termChar, int readTimeout = 10000) { if (stream.CanTimeout) stream.ReadTimeout = readTimeout;
@patwhite can you send me a pull request?