Closed ghost closed 10 years ago
I suspect gmail who is closing the connection. You can listen for the disconnect event and try to reconnect inside the disconnect event callback.
This is what I am doing:
https://gist.github.com/developernoman/9031636
Will that make it run forever ?
I have the same problem. The code:
mailListener.on("server:disconnected", function(){
console.log("imap server has been Disconnected");
// re-connect
mailListener.start();
});
doesn't work for me. I solved the issue starting node script on Linux from upstart script which has set respawn option and on disconnect event exit from node script like below:
mailListener.on("server:disconnected", function(){
setTimeout(function(){
//mailListener.start();
console.log("exirt after disconnect");
process.exit(0);
}, 5000)
});
Meybe this helps you?
@pwldp :+1:
Exactly what i suggested here: https://gist.github.com/developernoman/9031636.
Hi. I am now running into the exact same thing, but it appears that the IMAP connect never gets re-established:
mailListener.on("server:connected", function(){ console.log("INFO: IMAP Server Connected"); });
mailListener.on("server:disconnected", function(){ console.log("INFO: IMAP Server Disconnected"); // Reconnect mailListener.start(); console.log("INFO: Restarting IMAP connection"); });
I see that the disconnection happens in the logs, but then it never reconnects. Got any suggestions?
@BlueDevil2k6 follow @pwldp's answer or https://gist.github.com/developernoman/9031636
I'm doing exactly this, but it is not working. Now I'm starting to wonder if there's something my PaaS provider (OpenShift) is doing to terminate the ports and causing the reconnect to not work.
On Thu, Nov 5, 2015 at 4:20 AM, Chirag notifications@github.com wrote:
@BlueDevil2k6 https://github.com/BlueDevil2k6 follow @pwldp https://github.com/pwldp's answer or https://gist.github.com/developernoman/9031636
— Reply to this email directly or view it on GitHub https://github.com/chirag04/mail-listener2/issues/8#issuecomment-154044065 .
it could be that. I'm not sure what can be done here. Let me know if you find anything.
@chirag04 your link not working. please check
@chirag04 the link seems removed. please check
We are using Gmail(IMAP) to listen for emails in our application and it seems the listener disconnects at times.
Can you tell me what could the reason be if it has to do with code ?
We are listening for all events and our main application does not crash, only the listener disconnects.
Plus, if there a way to reconnect ? Sort of a container I can run listener inside that makes sure it reconnects when it disconnects ?