login about faq

I have this code for opening a connection to a pop3 server (in my case, hotmail

    if (MySession.Current.Pop3 == null)
                    MySession.Current.Pop3 = POP3Utils.GetPop3NewInstance();

                    //login checks
                    if (!POP3Utils.Login(MySession.Current.Pop3, imapAddress.ImapHost, imapAddress.Port, MySession.Current.userEmail, MySession.Current.userPassword))
                        //threat 15 minutes error usually coming for hotmail users
                        if (MySession.Current.Pop3.LastErrorText.Contains("Exceeded the login limit for a 15 minute period"))
                            TempData.Add("error", Resources.Resources.ExportPop315MinutesWarning);
                            return RedirectToAction("Retry", "Login");
                        //incorrect login
                            TempData.Add("error", Resources.Resources.ExportInvalidCredentials);
                            return RedirectToAction("Retry", "Login");

   ViewBag.TotalEmails = MySession.Current.Pop3.GetMailboxCount();

As you notice, first time I create a pop3 instance with the unlock code, login and get total emails number from the server.

Well, all works nice but after a few minutes of inactivity, if I try to do another operation (for instance do a filter) POP3Utils.MakeSureSessionIsLive(MySession.Current.Pop3) is called:

 public static void MakeSureSessionIsLive(MailMan mailman)
        bool noop = mailman.Pop3Noop();
        if (!noop)
            Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(String.Format("Succcesfully REINITIALIZED session for account {0}", mailman.PopUsername)));

and of couse, the noop is false and session is reinitialized. But from here on, each operation returns a NULL bundle. And any other operation I do from here on, when I check if the session is alive it ALWAYS goes and reinit it...

Can you please let me know where I am wrong? If after a few minutes of inactivity the session is re-init, why from there on it always try to reinit it for any operation?

UPDATE: When trying to send first noop after a period of idle (few minutes), I notice this in LastErrorText: ...WSAECONNRESET An existing connection was foribly closed by the remote host...NOOP Failed.

So what I understand from here is that I should not call NOOP when the user is coming back from IDLE but send NOOP continuously (for instance one noop per x seconds). But my question is not: HOW I do this? I cannot use Quartz because I keep current user connection in session which is not available in a quartz job... Is any way Chilkat thought of this issue's workaround?

asked Aug 18 '12 at 05:07

Cristian's gravatar image


Please post the full contents of the LastErrorText captured after calling mailman.Pop3BeginSession (from the code snippet that is within the "if (!noop)" statement. Also, make sure to check the success/failure return value of Pop3BeginSession. You shouldn't assume that it will succeed because anything involving network communications shouldn't assume success.


answered Aug 18 '12 at 08:43

chilkat's gravatar image

chilkat ♦♦

Thanks for your answer. After I modified my code to detect false response from Pop3BeginSession I noticed that it always returns true and the log contains IsSMTPconnected... Is there anything else I can do? Its really strange to see that BeginSession is succeded and for the next operation it again return fails when sending noop but return success again when doing BeginSession

(Aug 18 '12 at 11:34) Cristian

Then please examine the LastErrorText after whatever operation returns a failed status.

(Aug 18 '12 at 21:52) chilkat ♦♦

I've updated my question, can you please have a look?

(Aug 20 '12 at 17:45) Cristian
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Aug 18 '12 at 05:07

Seen: 5,944 times

Last updated: Aug 20 '12 at 17:45

powered by OSQA