Connection to server is not possible
See original GitHub issueHi, I’m trying to recover an email from Gmail account but I can’t because the method once in the state ready is never in that state. Here is the code:
var Imap = require('imap'),
inspect = require('util').inspect;
var imap = new Imap({
user: 'xyz@gmail.com',
password: 'xyz',
host: 'imap.gmail.com',
port: 993,
tls: true
});
console.log("*-*-*-*-*-* Starting email process");
function openInbox(cb) {
//Opens a specific mailbox that exists on the server
console.log("..Opening INBOX..");
imap.openBox('INBOX', true, cb);
}
imap.connect();
//sleep.sleep(5);
console.log(imap);
imap.once('ready', function() {
console.log("Entering once method");
The problem is the method once(ready) is never ready I don’t know why. Here is the console output:
Connection {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
_config:
{ localAddress: undefined,
socket: undefined,
socketTimeout: 0,
host: 'imap.gmail.com',
port: 993,
tls: true,
tlsOptions: undefined,
autotls: undefined,
user: 'xyz@gmail.com',
password: 'xyz',
xoauth: undefined,
xoauth2: undefined,
connTimeout: 10000,
authTimeout: 5000,
keepalive: true },
_sock:
TLSSocket {
_tlsOptions:
{ pipe: undefined,
secureContext: [Object],
isServer: false,
requestCert: true,
rejectUnauthorized: true,
session: undefined,
NPNProtocols: undefined,
ALPNProtocols: undefined,
requestOCSP: undefined },
_secureEstablished: false,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: null,
alpnProtocol: null,
authorized: false,
authorizationError: null,
encrypted: true,
_events:
{ close: [Function],
end: [Object],
finish: [Function: onSocketFinish],
_socketEnd: [Function: onSocketEnd],
secureConnect: [Object],
connect: [Object],
secure: [Function],
error: [Function],
timeout: [Function],
readable: [Function] },
_eventsCount: 10,
connecting: true,
_hadError: false,
_handle:
TLSWrap {
bytesRead: 0,
_externalStream: {},
fd: -1,
_parent: [Object],
_parentWrap: [Object],
_secureContext: [Object],
reading: true,
owner: [Circular],
onread: [Function: onread],
writeQueueSize: 1,
onhandshakestart: [Function],
onhandshakedone: [Function],
onocspresponse: [Function],
onerror: [Function] },
_parent:
Socket {
connecting: true,
_hadError: false,
_handle: [Object],
_parent: null,
_host: 'imap.gmail.com',
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
destroyed: false,
_bytesDispatched: 0,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1 },
_host: null,
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: null,
ended: false,
endEmitted: false,
reading: false,
sync: true,
needReadable: true,
emittedReadable: false,
readableListening: true,
resumeScheduled: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: true,
domain: null,
_maxListeners: undefined,
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: false,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: true,
allowHalfOpen: false,
destroyed: false,
_bytesDispatched: 0,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl:
TLSWrap {
bytesRead: 0,
_externalStream: {},
fd: -1,
_parent: [Object],
_parentWrap: [Object],
_secureContext: [Object],
reading: true,
owner: [Circular],
onread: [Function: onread],
writeQueueSize: 1,
onhandshakestart: [Function],
onhandshakedone: [Function],
onocspresponse: [Function],
onerror: [Function] },
_requestCert: true,
_rejectUnauthorized: true },
_tagcount: 0,
_tmrConn:
Timeout {
_called: false,
_idleTimeout: 10000,
_idlePrev:
TimersList {
_idleNext: [Circular],
_idlePrev: [Circular],
_timer: [Object],
_unrefed: false,
msecs: 10000 },
_idleNext:
TimersList {
_idleNext: [Circular],
_idlePrev: [Circular],
_timer: [Object],
_unrefed: false,
msecs: 10000 },
_idleStart: 14034,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: null },
_tmrKeepalive: undefined,
_tmrAuth: undefined,
_queue: [],
_box: undefined,
_idle: { started: undefined, enabled: false },
_parser:
Parser {
domain: null,
_events:
{ untagged: [Function],
tagged: [Function],
body: [Function],
continue: [Function],
other: [Function] },
_eventsCount: 5,
_maxListeners: undefined,
_stream:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: false,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: null,
alpnProtocol: null,
authorized: false,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: true,
_hadError: false,
_handle: [Object],
_parent: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
destroyed: false,
_bytesDispatched: 0,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [Object],
_requestCert: true,
_rejectUnauthorized: true },
_body: undefined,
_literallen: 0,
_literals: [],
_buffer: '',
_ignoreReadable: false,
debug: undefined,
_cbReadable: [Function] },
_curReq: undefined,
delimiter: undefined,
namespaces: undefined,
state: 'disconnected',
debug: undefined,
_onError: [Function],
_onSocketTimeout: [Function] }
thanks for your help.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
5 Ways to Fix Unable To Connect To Server
5 Ways to Fix Unable To Connect To Server · 1. Check Internet Connection · 2. Restart Device · 3. Check Date &...
Read more >What does "Can't Connect to Server" mean, and how to fix it?
Some software may have an issue with it, and when it requests a resource from the server, due to a software error, it...
Read more >"Cannot connect the computer to the server" error message ...
Cannot connect the computer to the server because either another software installation is in progress or, the computer has a restart pending.
Read more >Effective Ways To Fix "Couldn't Open Connection To Server"
Step 1: Restarting your Device · Step 2: Check if the Network Connection is working fine · Step 3: Is your SIM okay?...
Read more >I Cannot Connect to the Server
To check that the server and network are working correctly, try to ping the server from your computer. If you cannot ping the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The output is this:
but I cann’t open the mailbox using this way:
the imapObject is just like this:
please anyone know whats going on because the result in the console is just:
I don’t understand what’s happening?? Please help
Thanks… It is working for me … I assume because of synchronisation issue in my code this happen.