I use Node.js script to process incoming emails and pipe them from Postfix via netcat in mailbox_command (namely: nc 127.0.0.1 3002). Node is listening on port 3002 and calls socket.destroy() once email is processed.
However, it seems that postfix does not recognize that command succeeded and retries. Well, I'm not sure that this is postfix who causes the issue, it's just a suggestion. Some facts:
- Socket IS closed after the email is processed. Otherwise, after 12 incoming messages Node warns about possible memory leak. So I assume that netcat exits thus does not cause this issue.
- If I spawn Node process with mailbox_command (consuming stdin instead of socket) which then exits with code 0 postfix does not try to call mailbox_command once again.
- If I use -q option for netcat (e.g. nc -q 1 127.0.0.1 3002) node does not receive anything
Once the email is processed I log a timestamp. This is log for a single email:
socket destroyed at: Fri Mar 28 2014 05:07:25 GMT-0400 (EDT)
socket destroyed at: Fri Mar 28 2014 05:11:25 GMT-0400 (EDT) socket destroyed at: Fri Mar 28 2014 05:11:25 GMT-0400 (EDT)
socket destroyed at: Fri Mar 28 2014 05:18:35 GMT-0400 (EDT) socket destroyed at: Fri Mar 28 2014 05:18:35 GMT-0400 (EDT) socket destroyed at: Fri Mar 28 2014 05:18:35 GMT-0400 (EDT)
socket destroyed at: Fri Mar 28 2014 05:18:51 GMT-0400 (EDT) socket destroyed at: Fri Mar 28 2014 05:18:51 GMT-0400 (EDT) socket destroyed at: Fri Mar 28 2014 05:18:51 GMT-0400 (EDT) socket destroyed at: Fri Mar 28 2014 05:18:51 GMT-0400 (EDT)
Note highlighted time. As you can see, it retries n+1 times, but there's no fixed retry timeout.
Please, help me fix this.