-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logger - socket exception #428
Comments
I think the log is doing its job and capturing some sort of error. Any chance you could share the whole log? Is it associated with a video stream disconnect or something? |
Not capturing at the moment, unfortunately I can't download the whole log at the moment |
oh, interesting. It's no even capturing... |
It could be this bit: RMS/RMS/Formats/ObservationSummary.py Lines 194 to 217 in 4ab05b0
Maybe, wrap it in a try-except block and add a timeout? def timestampFromNTP(addr='0.us.pool.ntp.org'):
REF_TIME_1970 = 2208988800 # Reference time
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set the socket timeout (e.g., 5 seconds)
client.settimeout(5)
try:
data = b'\x1b' + 47 * b'\0'
client.sendto(data, (addr, 123))
data, address = client.recvfrom(1024)
if data:
t = struct.unpack('!12I', data)[10]
t -= REF_TIME_1970
return t
except socket.error as e:
print("Socket error: {}".format(e))
return None
finally:
client.close() |
Unlikely, that code has no business running at this stage. |
Yes, you are right. I see that now. Sorry. Maybe something around her?: Line 1292 in 4ab05b0
|
That code executes at the start of an EventMonitor run, which is not yet due. |
So the error is occurring while the program is in this loop: Line 2127 in 4ab05b0
Which calls this function: Line 2084 in 4ab05b0
Which calls: Line 1292 in 4ab05b0
Which runs: Line 1310 in 4ab05b0
Maybe warp it in a try:
if sys.version_info[0] < 3:
with urllib2.urlopen(self.syscon.event_monitor_webpage) as response:
web_page = response.read().splitlines()
else:
with urllib.request.urlopen(self.syscon.event_monitor_webpage) as response:
web_page = response.read().decode("utf-8").splitlines()
except (socket.error, urllib2.URLError, urllib.error.URLError) as e:
log.error("Socket or URL error in getEventsfromWebPage: {}".format(e))
return events
except Exception as e:
log.error("Unexpected error in getEventsfromWebPage: {}".format(e))
return events |
Error was raised at 09:52:11, that code ran successfully at 09:40:15 and was not scheduled to run again until 10:10:18. Why do you think it is that code that had the exception? |
A likely cause of the error is that a socket is being opened but not properly closed by the client. If the client fails to close the socket after completing its operation, the server may eventually close the connection after a period of inactivity, which is what the “Connection reset by peer” message suggests. This typically happens when the server forcefully terminates an idle or incomplete connection. It’s also important to note that there can be a delay between when the socket is opened and when the server closes it. The message may not appear immediately after the socket is opened but rather after the server detects inactivity or hits a timeout, which can occur several minutes later. It'd be worth trying using a with statement when opening the socket ensures that the connection is properly closed on the client side once the operation is complete. |
Also, I think the code as it is keeps opening a new socket every 30 minutes without ever closing them. |
RMS/RMS/Logger.py
Line 44 in 4ab05b0
On prerelease Pi4, seeing sporadic messages referring to this line.
2024/09/25 09:52:11-INFO-Logger-line:44 - Socket exception: Connection reset by peer (104)
I don't understand what is happening here, apologies for this not being a very helpful submission.
The text was updated successfully, but these errors were encountered: