haraka / haraka-plugin-rspamd

Rspamd plugin for Haraka
https://www.npmjs.com/package/haraka-plugin-rspamd
MIT License
15 stars 14 forks source link

Error: Cannot pipe while currently piping #5

Closed simonszu closed 6 years ago

simonszu commented 6 years ago

system info

Haraka Haraka.js — Version: 2.8.18
Node v9.10.0
OS Linux 5c31aaa9ffc0 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
openssl OpenSSL 1.0.1t 3 May 2016

Expected behavior

Inbound mail gets piped to rspamd, rspamd processes the mail, and reports it back to Haraka

Observed behavior

[INFO] [10CB0DC5-76EA-415E-899B-5904750B604F.1] [core]  hook=rcpt plugin=rcpt_to.alias_forward function=alias_forword params=<mail@simonszu.de> retval=OK msg=""
[NOTICE] [10CB0DC5-76EA-415E-899B-5904750B604F.1] [core] recipient <mail@simonszu.de> code=OK msg="" sender=mail@simonszu.de
[CRIT] [10CB0DC5-76EA-415E-899B-5904750B604F.1] [core] Plugin rspamd failed: Error: Cannot pipe while currently piping
    at MessageStream.pipe (/home/node/.npm-global/lib/node_modules/Haraka/messagestream.js:324:19)
    at Plugin.exports.hook_data_post (/home/node/.npm-global/lib/node_modules/Haraka/node_modules/haraka-plugin-rspamd/index.js:163:43)
    at Object.plugins.run_next_hook (/home/node/.npm-global/lib/node_modules/Haraka/plugins.js:505:28)
    at Object.plugins.run_hooks (/home/node/.npm-global/lib/node_modules/Haraka/plugins.js:422:13)
    at MessageStream.end_callback (/home/node/.npm-global/lib/node_modules/Haraka/connection.js:1605:21)
    at MessageStream._write (/home/node/.npm-global/lib/node_modules/Haraka/messagestream.js:137:41)
    at ChunkEmitter.<anonymous> (/home/node/.npm-global/lib/node_modules/Haraka/messagestream.js:63:22)
    at ChunkEmitter.emit (events.js:180:13)
    at ChunkEmitter.end (/home/node/.npm-global/lib/node_modules/Haraka/chunkemitter.js:58:18)
    at MessageStream.add_line_end (/home/node/.npm-global/lib/node_modules/Haraka/messagestream.js:114:28)
[NOTICE] [17C9FE55-F6E7-4220-A565-84190D48522E.1] [core] message mid=<17C9FE55-F6E7-4220-A565-84190D48522E.1@tharan.simonszu.de><17C9FE55-F6E7-4220-A565-84190D48522E.1@tharan.simonszu.de>

<09d40d7b72932142724358036c59e0ee.squirrel@webmail.tu-dortmund.de>
 size=957 rcpts=1/0/0 delay=0.012 code=CONT msg=""
[NOTICE] [17C9FE55-F6E7-4220-A565-84190D48522E.1] [core] queue code=CONT msg=" (17C9FE55-F6E7-4220-A565-84190D48522E.1)"
[CRIT] [-] [core] Error: connect ECONNREFUSED 172.19.1.29:11333
[CRIT] [-] [core]     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1173:14)
[NOTICE] [-] [core] Shutting down

and haraka crashing after that (please ignore any domains in this error log, it was pasted together from two subsequent crashes, maybe the domains do not fit together. However, the log is the same)

Steps to reproduce

Install Haraka with the following plugins enabled (in this order):

Rspamd is on another host (speak: docker container) with the following config:

host = rspamd_app_1
port = 11333
add_headers = sometimes

[dkim]
enabled = true

[header]
bar = X-Rspamd-Bar
report = X-Rspamd-Report
score = X-Rspamd-Score

[check]
authenticated=false
private_ip=false

[reject]
message = Detected as spam
authenticated=false
spam = true

[rmilter_headers]
enabled = true

[spambar]
positive = +
negative = -
neutral = o

Wait until Haraka gets an inbound mail to process.

simonszu commented 6 years ago

Hm, this could be a problem of the rcpt_to.alias_forward plugin as well...

msimerson commented 6 years ago

The previous issues we had with dkim_sign throwing this error might prove helpful to you. Here's a repo search cannot pipe while currently piping.

msimerson commented 6 years ago

I took a quick look at rcpt_to.alias_forward plugin and you need to be more careful of flow control and making sure to call next() exactly once.