You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
logging.handlers.DatagramHandler sends bad data to socketserver.DatagramRequestHandler #81512
attachment.md: UDP server receive for syslog message
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2019-06-19.14:43:45.926>created_at=<Date2019-06-18.19:37:02.385>labels= ['3.8', 'type-bug', '3.7', '3.9', 'docs']
title='logging.handlers.DatagramHandler sends bad data to socketserver.DatagramRequestHandler'updated_at=<Date2019-06-19.14:43:45.925>user='https://github.com/yoonghm'
A UDP server listens at 0.0.0.0:514 for syslog messages.
syslogmsg_gen.py
Send syslog message to local syslog server via 127.0.0.1:514
Error:
Exception has occurred: UnicodeDecodeError
'utf-8' codec can't decode byte 0xd7 in position 381: invalid continuation byte
File "C:\pysyslog.py", line 21, in handle
data = self.request[0].decode('utf-8')
File "C:\pysyslog.py", line 28, in <module>
server.serve_forever(poll_interval=0.5)
logging.handlers.DatagramHandler() sends data in the following format:
message length
message itself which consists of
a. Creation time in ASCII format
b. Creation time in seconds, ms
c. Filename, line no
d. Message level
e. Message
f. Logger name
etc.
Item 1. is packed using struct.pack(">L")
Item 2. is packed using pickle
The message format is not mentioned in any of the standard Python document. Also it may not be compatible with third-party syslog message library or generator.
New changeset b64e42e by Vinay Sajip (Miss Islington (bot)) in branch '3.7': bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234) (GH-14236) b64e42e
New changeset d7232f0 by Vinay Sajip (Miss Islington (bot)) in branch '3.8': bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234) (GH-14235) d7232f0
Activity
yoonghm commentedon Jun 18, 2019
pysyslog.pysyslogmsg_gen.pyError:
Exception has occurred: UnicodeDecodeError
'utf-8' codec can't decode byte 0xd7 in position 381: invalid continuation byte
File "C:\pysyslog.py", line 21, in handle
data = self.request[0].decode('utf-8')
File "C:\pysyslog.py", line 28, in <module>
server.serve_forever(poll_interval=0.5)
yoonghm commentedon Jun 19, 2019
I did some checks, I discovered the following:
logging.handlers.DatagramHandler() sends data in the following format:
a. Creation time in ASCII format
b. Creation time in seconds, ms
c. Filename, line no
d. Message level
e. Message
f. Logger name
etc.
Item 1. is packed using struct.pack(">L")
Item 2. is packed using pickle
The message format is not mentioned in any of the standard Python document. Also it may not be compatible with third-party syslog message library or generator.
vsajip commentedon Jun 19, 2019
It is mentioned here:
https://docs.python.org/3/library/logging.handlers.html?highlight=datagramhandler#logging.handlers.SocketHandler.makePickle
although that doesn't go into the detail of the struct.pack format. I'll update the documentation to rectify this.
vsajip commentedon Jun 19, 2019
New changeset f06b569 by Vinay Sajip in branch 'master':
bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234)
f06b569
vsajip commentedon Jun 19, 2019
New changeset b64e42e by Vinay Sajip (Miss Islington (bot)) in branch '3.7':
bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234) (GH-14236)
b64e42e
vsajip commentedon Jun 19, 2019
New changeset d7232f0 by Vinay Sajip (Miss Islington (bot)) in branch '3.8':
bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234) (GH-14235)
d7232f0