Open leeliu opened 11 years ago
after the client sends QUIT it should completely read the "Goodbye" message, otherwise the server has written, and the client has failed to read what was written before closing (or calling shutdown for read operations). this results in ECONNRESET on the server side (which is safe to ignore in that example). so that is a broken client. but how to handle it?
i believe i am experiencing the same problem with similar conditions: a monitor service connects to my simplesmtp server and then calls close() before reading the SMTP banner. again, safe to ignore.
but whether these can be ignored or not with respect to all the rest of SMTP protocol depends on when it happens. so it does need to be thrown, and it does need to be caught and handled.
i have verified that this is possible in windows with v.0.10.30 and while i don't yet see the bug in RAI, something is clearly wrong. my uncaughtException handler always gets it, not the appropriate handler. i have to +1 this because it may very well be removeAllListeners() that's responsible.
EPIPE is a similar error: a write() after closing the descriptor.
http://linux.die.net/man/3/recv http://linux.die.net/man/3/send http://linux.die.net/man/3/shutdown
I am getting this error, when I use MacOS Mail APP
Connection closed
events.js:174
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at WriteWrap.afterWrite [as oncomplete] (net.js:779:14)
Emitted 'error' event at:
at RAISocket._onError (/bms/smtp/node_modules/rai/lib/rai.js:450:10)
at Socket.emit (events.js:189:13)
at onwriteError (_stream_writable.js:431:12)
at onwrite (_stream_writable.js:456:5)
at _destroy (internal/streams/destroy.js:40:7)
at Socket._destroy (net.js:604:3)
at Socket.destroy (internal/streams/destroy.js:32:8)
at WriteWrap.afterWrite [as oncomplete] (net.js:781:10)
tried workaround
process.stdin.on('error', function () {
console.error("Ignore EPIPE and ECONNRESET.");
});
didnt help, my app exiting due to error
Using apple mail with simplesmtp, apple mail connects to test smtp user/pass (during testing, i just change the password by a few chars), it does a quick AUTH PLAIN check, then QUITs. Immediately following this, about 50% of the time, the connection somehow quits uncleanly and results in a crash of node with ECONNRESET or EPIPE.
I debugged it a bit and i think it's due to unhandled socket errors, since RAISocket _destroy() (rai.js:434) has removeAllListeners() which removes on("error") which i think is how net.js detects it as unhandled and crashes.