mscdex/node-imap — Issue #50: No timeout when establishing a secure-only conn as non-secure.
Author: cloudily
Created: 2012-03-09 20:50:09+00:00
State: open

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:

```javascript
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:

```javascript
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