Closed d-cui closed 5 years ago
Gnirehtet logs always look like this
You should enable debug logs here.
Every second, I use
adb shell curl --max-time 1 10.0.2.2:8080
to confirm that networking is still working as intended. However, roughly every 7 minutes (not exactly), networking fails.
When this happens, does curl
hang or return with an error?
Gnirehtet logs always look like this (an invalid packet is dropped every 4-6 seconds). There's no change when networking appears to fail:
Do you still see Open/Close connections when it "fails"? What failure do you observe then?
Does this happen both with the Rust and the Java version of gnirhetet?
It feels like something is filling up because the timing is so consistent -- possibly some type of logging, data usage, etc?
I don't know what could cause this.
Thanks @rom1v ! I think I've figured out a solution to the bug, but am not sure what the underlying cause is.
I recompiled the Rust version of gnirehtet using loglevel Debug. Immediately, the issue started presenting itself with higher frequency. Instead of failing every 6-7 minutes, the networking would fail every 15-20s.
My suspicion is that there is some buffer being overflown when the output to stdout is not read.
Original code (causes intermittent networking failures):
shell_string = os.path.join(
HOME, "drivers/gnirehtet-rust-linux64/gnirehtet") + " autorun"
self.gnirehtet_proc = subprocess.Popen(
shell_string, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Fix:
"""
Reads output from the gnirehtet process.
"""
# Continuously call readline until the output is an empty bytestring
# This means that stdout has been closed, which happens after the child exits
for line in iter(self.gnirehtet_proc.stdout.readline, b''):
rospy.loginfo("[GNIREHTET] {}".format(line))
# Start a new instance of gnirehtet and spy on it
shell_string = os.path.join(
HOME, "drivers/gnirehtet-rust-linux64/gnirehtet") + " autorun"
self.gnirehtet_proc = subprocess.Popen(
shell_string, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
reader = threading.Thread(target=self.gnirehtet_reader)
reader.start()
When the networking "fails," the curl command hangs. Let me know if you have any thoughts!
My suspicion is that there is some buffer being overflown when the output to stdout is not read.
Ah, yes, the stdout buffer is limited, any write will block once full.
If you don't need logs, just pass stdout=None
to subprocess.Popen
.
I'm experiencing an issue where networking over Gnirehtet fails intermittently (roughly every 7 minutes, but not exactly).
I have an Android tablet connected to a Linux machine over USB. The Linux machine acts as a webserver and serves assets to the tablet at port 8080.
Every second, I use
adb shell curl --max-time 1 10.0.2.2:8080
to confirm that networking is still working as intended. However, roughly every 7 minutes (not exactly), networking fails.I can resolve the issue by restarting Gnirehtet and reloading the webpage on the tablet (I am automating this right now), however this is undesirable as it leads to significant downtime.
Gnirehtet logs always look like this (an invalid packet is dropped every 4-6 seconds). There's no change when networking appears to fail:
Logcat doesn't look unusual either, except for the intermittent Gnirehtet restarts. The output of
adb logcat *:D | grep gnirehtet
is:I've checked the number of TCP connections formed over Gnirehtet, and it doesn't look like there's a connection leak there. Memory usage of Gnirehtet also appears to be stable in
htop
.Any ideas on how to proceed with further debugging? It feels like something is filling up because the timing is so consistent -- possibly some type of logging, data usage, etc?