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

The POP3 server has unexpectedly disconnected #174

Closed
mrjozo opened this issue Apr 8, 2015 · 9 comments
Closed

The POP3 server has unexpectedly disconnected #174

mrjozo opened this issue Apr 8, 2015 · 9 comments
Labels
bug Something isn't working

Comments

@mrjozo
Copy link

mrjozo commented Apr 8, 2015

Hi,

tried new version from github with fixed \r\n and got next problem:

The POP3 server has unexpectedly disconnected.

 at MailKit.Net.Pop3.Pop3Stream.ReadAhead(CancellationToken cancellationToken)

client.Connect(ConfigStorage.Instance.ProjectData.GetElementValueAsString("emailServer"),
                    int.Parse(ConfigStorage.Instance.ProjectData.GetElementValueAsString("emailPort")),
                    Convert.ToBoolean(ConfigStorage.Instance.ProjectData.GetElementValueAsString("emailUseSSL")),
                    ConfigStorage.Instance.CTS.Token);
              client.Authenticate(ConfigStorage.Instance.ProjectData.GetElementValueAsString("emailUser"),
                    ConfigStorage.Instance.ProjectData.GetElementValueAsString("emailPassword"),
                    ConfigStorage.Instance.CTS.Token);

              var saChunk = new List<int>();

              for (var j = 0; j < 10; j++)
              {
                 saChunk.Add(j);
              }
              var b = client.GetMessages(saChunk);

Log

Connected to pop://poczta.o2.pl:110/?starttls=when-available
S: +OK POP3 ready
C: CAPA
S: +OK Capability list follows
S: LAST
S: TOP
S: USER
S: PIPELINING
S: UIDL
S: SASL LOGIN PLAIN
S: STLS
S: .
C: STLS
S: +OK
C: CAPA
S: +OK Capability list follows
S: LAST
S: TOP
S: USER
S: PIPELINING
S: UIDL
S: SASL LOGIN PLAIN
S: .
C: AUTH PLAIN
S: + 
C: XXXXXXXXXXXXXXXXXXXXXXX
S: +OK
C: CAPA
S: -ERR
C: STAT
S: +OK 12338 2153983759
C: RETR 2
C: RETR 3
C: RETR 4
C: RETR 5
C: RETR 6
C: RETR 7
C: RETR 8
C: RETR 9
C: RETR 10
C: RETR 11
S: +OK
S: Received: by o2.pl (o2.pl mailsystem) with LMTP;
S:  Thu, 12 Jun 2014 19:46:03 +0200
more lines with S
S: /></body>
S: </html>
S: 
S: 
S: 
S: --b1_412ecde77cc960066f69e099e0527507--
S: 
S: 
S: .

@jstedfast
Copy link
Owner

Try downloading 1 message at a time

@mrjozo
Copy link
Author

mrjozo commented Apr 8, 2015

It is ok when downloading one at time

@jstedfast
Copy link
Owner

The problem, I suspect, is that your server advertises that it supports PIPELINING, but doesn't actually support it.

You'll notice above in the log that MailKit requests a bunch of messages (all those RETR commands) in a pipelined fashion, but the server only replies with a single message.

Or did you cut out more than just the content of a single message?

@mrjozo
Copy link
Author

mrjozo commented Apr 8, 2015

I cut out messages content and replace it with "more lines with S"

@jstedfast
Copy link
Owner

Did you cut out any "S: +OK"'s? That's what I was asking.

@mrjozo
Copy link
Author

mrjozo commented Apr 8, 2015

Sorry for my misunderstood, here are 2 full logs:

http://pastebin.com/e9qV76XH
http://pastebin.com/qbi439YU

@jstedfast
Copy link
Owner

Okay, so, I think that the problem is that the server is only responding with a single message even though you asked for ~10 or so in each session.

jstedfast added a commit that referenced this issue Apr 9, 2015
…back handler

This way, if the server replies with -ERR in a subsequent CAPA query,
all capabilities are cleared. If the clearing happens in the callback
handler, then they are only updated if the server replies with a +OK
response.

Fixes issue #174
@jstedfast
Copy link
Owner

Looking at your log again, I saw this after authenticating:

C: CAPA
S: -ERR

This should probably clear our list of capabilities which would cause us to not even try to take advantage of PIPELINING.

I also confirmed that your server is broken with PIPELINING using wireshark. As I suspected, it only responds to a single RETR command and ignores the rest which is what causes MailKit to sit there waiting forever until the TCP connection times out and throws an exception.

@jstedfast
Copy link
Owner

BTW, you may want to change your password since you forgot to X-out your base64'd user/password string both in your original bug report and in those pastebin links.

I've X'd it out in your original bug report, but I can't change the pastebin entries.

@jstedfast jstedfast added the bug Something isn't working label Apr 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants