Web Interface learning Spam/Ham, cannot learn from command line

TomJones

Verified User
Joined
May 9, 2004
Messages
78
As the title says, Rspamd (and Redis) is installed and working, but I cannot bayes train from the command line. When I try to train it, I always get:

[root@host ~]# rspamc learn_spam /tmp/test.eml Results for file: /tmp/test.eml (0.000 seconds) IO write error: Connection refused

I also get the same when I try to stat:
[root@host ~]# rspamc -h 127.0.0.1:11334 stat Results for command: stat (0.000 seconds) IO write error: Connection refused

I CAN train from the web interface, but that would take me a loooong time to copy/paste the 3,500 .eml files through the interface. Been working at this all day, I'm at a wall for things to search/try.

Any help is greatly appreciated!
 
Searching the Rspamd code base on GitHub, there are two files that throw the "IO write error:"
src/libserver/http/http_connection.c
src/libserver/milter.c

Since there is no error number in the message, I'm assuming it's not an http connection error and must be something to do with milter, but that's all I can figure out. I'm still seeing dozens of spam getting through each day and the rspamd log says it's ignoring bayes until it gets trained on 200 messages, so I guess I'll see where the 200 message requirement is set and see if I can lower that to get the bayes filtering to start working...
 
I'm thinking about installing Rspamd/Redis on a local testing machine and seeing if I can get that working. If I can get that working, maybe I can scan all my spam/ham files and then just upload/replace the redis data on the server. Sounds doable, but I have zero experience with Redis...
 
I didn't before, but I just did now and there was no difference. I get the same response/message when I issue the 'stat' command with rspamc (which doesn't involve scanning a file/folder). It does seem like a permission-issue, but not a simple one.

I've been trying to get Rspamd setup over the last month+. I followed several different guides, so I'm thinking I might have introduced the issue. I would strip it all out and start over, but it's working currently, just isn't flagging obvious spam because I haven't trained it beyond a few dozen spam emails.
 
It does seem like a permission-issue, but not a simple one.
Yes I was thinking of that and then the /tmp chmod 1777 came into my mind, which some times caused some issues with certain applications in the past.
The only other thing I can think of that it works over a certain port, but unless you're running something like modsec there should not be any issue for using local ports. So indeed not a simple issue.
Hope you'll find it or somebody brings you on the right track.
 
@TomJones did tou resolve the problem?
I know for today that normal worker dosen't start.
Can you check that worker is running by:
Code:
 ss -l | grep 11334
I have empty result.

I'm not sure why. Hard to judge from log.
I'm not sure if these lines are correct (when rspamd is running):
Code:
2022-10-20 13:00:29 #17971(normal) <632b2b>; lua; arc.lua:699: cannot read key from /var/lib/rspamd/arc/domain.com.arc.key: There is no such file or directory
2022-10-20 13:01:27 #17972(normal) <42dd04>; task; lua_task_set_settings: disabled action greylist due to settings

I'm not sure if these lines are correct (when rspamd is starting):
Code:
2022-10-20 13:03:05 #51866(main) lua; lua_cfg_transform.lua:161: group excessqp has no symbols
2022-10-20 13:03:05 #51866(main) lua; lua_cfg_transform.lua:161: group excessb64 has no symbols
2022-10-20 13:03:05 #51866(main) rspamd_inet_address_listen: bind unix:/var/lib/rspamd/rspamd.sock failed: 98, 'The address is already in use'
2022-10-20 13:03:05 #51878(rspamd_proxy) <9d9671>; main; rspamd_worker_set_limits: use system max file descriptors limit: 1024KiB cur and 1024KiB max
2022-10-20 13:03:05 #51878(rspamd_proxy) <9d9671>; main; rspamd_worker_set_limits: use system max core size limit: 0B cur and -1B max
024KiB max
2022-10-20 13:03:05 #51879(controller) <9d9671>; main; rspamd_worker_set_limits: use system max core size limit: 0B cur and -1B max
2022-10-20 13:03:05 #51881(normal) <9d9671>; main; rspamd_worker_set_limits: use system max file descriptors limit: 1024KiB cur and 1024KiB max
2022-10-20 13:03:05 #51881(normal) <9d9671>; main; rspamd_worker_set_limits: use system max core size limit: 0B cur and -1B max
2022-10-20 13:03:05 #51866(main) <9d9671>; main; rspamd_fork_worker: prepare to fork process hs_helper (0), no bind socket
2022-10-20 13:03:05 #51885(hs_helper) <9d9671>; main; rspamd_handle_child_fork: starting hs_helper process 51885 (0); no listen

I see in log:
Code:
2022-10-20 13:03:05 #51882(normal) <9d9671>; main; rspamd_handle_child_fork: starting normal process 51882 (2); listen on: localhost:11333
but the same for 11334 is unavailable.

I'm using Debian Buster. All apps in the newest versions (the same problem was occurred in older versions on Debian Stretch).

How it's possible that rspamd Web Interface work's fine (all functions with learning from RAW) but CLI not. CLI and Web Interface working with diffrent methods?

I'm using standard configuration but before i tried disabling firewall, changing ports and other weird things ;).

Please help - anyone, something?
 
@TomJones i figured this out.
Problem is because socket for web dosen't start.

add
Code:
bind_socket = "127.0.0.1:11334";
in /etc/rspamd/local.d/worker-controller.inc
 
@TomJones i figured this out.
Problem is because socket for web dosen't start.

add
Code:
bind_socket = "127.0.0.1:11334";
in /etc/rspamd/local.d/worker-controller.inc
My worker-controller.inc for looks like this:
Code:
bind_socket = "/var/run/rspamd/rspamd_controller.sock mode=0600 owner=_rspamd";

I managed to get enough Spam/Ham trained using Scan/Learn to get Bayes working, but I'm stuck with training on only 92 Spam and 31 Ham, I can't get it to train anymore. Each time I try to add another through the web interface it scans the messages successfully, but when I click either upload button the form responds with a "nocontent" every time.

I'm just glad it's working for the time being; I really hate seeing the same spam messages I know I could train away, but I don't have the time now to put into diagnosing the issue.
 
Last edited:
While I know this is a rather old thread, it came up in my search - so for those struggling with the same:

rspamc -h /var/run/rspamd/rspamd_controller.sock learn_spam <file>
 
Back
Top