No timeout when establishing a secure-only conn as non-secure. #50

Closed
cloudily opened this Issue Mar 9, 2012 · 3 comments

Projects

None yet

2 participants

@cloudily
cloudily commented Mar 9, 2012

Using the gmail example that you have listed on the readme and changing the secure flag to be false, you'll see that it just hangs open:

var ImapConnection = require('./imap').ImapConnection, util = require('util'),
    imap = new ImapConnection({
      username: 'mygmailname@gmail.com',
      password: 'mygmailpassword',
      host: 'imap.gmail.com',
      port: 993,
      secure: false
    });

Not sure if this is the best way to fix, but I added a listener for timeout and moved the timeout into the socket:

  this._state.conn.on("timeout", function() {
    self._fnTmrConn(loginCb);
  });  

  this._state.conn.setTimeout(this._options.connTimeout);
  this._state.conn.connect(this._options.port, this._options.host);
  //this._state.tmrConn = setTimeout(this._fnTmrConn.bind(this),
  //                                 this._options.connTimeout, loginCb);
};

Please let me know if you're seeing the same problem.

Thanks

@cloudily
cloudily commented Mar 9, 2012

I forgot to note that you must also call

self._state.conn.removeAllListeners("timeout");

where you're calling

clearTimeout(self._state.tmrConn);
@cloudily

Okay, that doesn't fix it. It's because the timeout gets cleared in the "connect" event. Commenting that out and adding it to the "ready" event seems to fix it but don't know what other issues will arise.

@mscdex
Owner
mscdex commented Dec 31, 2012

Fixed in 4e61905.

@mscdex mscdex closed this Dec 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment