Reputation: 17679
I'm writing a program that publishes messages to an rsyslog
TCP socket. My program should be able to publish any message. Unfortunately, when I try to publish certain types of messages - I get errors.
So far it seems to be failing consistently on messages that start with one or more digits. Here's a Python program that reliably produces these error on my local workstation:
import socket
s = socket.socket()
s.connect(('localhost', 514))
s.sendall(b'1\n')
Here is what this program causes to appear in /var/log/messages
, instead the the message "1":
Sep 1 16:08:52 dunpeal rsyslogd: Framing Error in received TCP message: delimiter is not SP but has ASCII value 10.
Sep 1 16:08:52 dunpeal rsyslogd: Incomplete frame at end of stream in session 0x7fe6e801cc80 - ignoring extra data (a message may be lost).
What is going on in here?
Upvotes: 3
Views: 2394
Reputation: 2529
Instead of sending raw socket messages to a syslog service, try using a logger instead, and adding the syslog handler to your logger. This is not only easier to set up, but will also allow you to send your log output to other handlers as you scale or modify your application.
Upvotes: 2