ArduPilot / ArduPilot/MAVProxy

Connection reset by peer in mavproxy_map

Open
#347 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
595
Forks
773
Avg merge
2d 6h
Merged PRs (30d)
18

Description

I was using MAVProxy in ardupilot simulator ( `Ardupilot/ardupilot/Tools/autotest/sim_vehicle.py` ) and faced connection error when using mavproxy_map.

* My command:

```
ardupilot/Tools/autotest/sim_vehicle.py -j 2 -v ArduCopter -f X --console --map
```

* stdout:

```
Loaded module console
Loaded module map
Unable to find parameter 'FRAME'
Log Directory:
Telemetry log: mav.tlog
MAV> Waiting for heartbeat from tcp:127.0.0.1:5760
Fontconfig warning: ignoring UTF-8: not a valid region tag
STABILIZE> Received 696 parameters
Saved 696 parameters to mav.parm
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/MAVProxy/modules/mavproxy_map/mp_tile.py", line 287, in downloader
img = resp.read()
File "/usr/lib/python2.7/socket.py", line 355, in read
data = self._sock.recv(rbufsize)
File "/usr/lib/python2.7/httplib.py", line 612, in read
s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 384, in read
data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer
```

I think it caused by a rack of error handling when UDP connection failed.
Then I added try-except all errors when reading response, it worked fine.

* `MAVProxy/modules/mavproxy_map/mp_tile.py` diff:

```diff
@@ -284,7 +284,11 @@ class MPTile:
print("non-image response %s" % url)
continue
else:
- img = resp.read()
+ try:
+ img = resp.read()
+ except Exception as e:
+ print(e.message)
+ img = ""
```

Can I make this PR? Any concern about this?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in MAVProxy/modules/mavproxy_map/mp_tile.py, especially MPTile.downloader and the resp.read() call; reproduce with the supplied sim_vehicle.py command. Done means a reset during tile retrieval no longer terminates the downloader thread and the map module continues running.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.