So I was trying to use the PPP session rather then the message router so I could send http requests directly from my Pi. When I open a session with hologram.network.connect(timeout=300) its works perfect.
I then do a hologram.network.disconnect() after the request is sent. Then the script sleeps for x minutes before doing the same process in a loop. My script runs hologram.network.getConnectionStatus() to check to make sure the session is not active. The script will return 0 for disconnected, and try to connect. It will then fail and state that pppd session is already active on process number xxxx in the error when it bombs.
In between the first and second loop of the script, if I run “sudo ps -A | grep pppd” the pppd session will show "pppd ". As soon as the script bombs out it disappears, and I can run it again for one loop. It works fine if I just run it once every time like a cron job, but its a background service that runs continuously.
Tested on Jessie running the python2 sdk, and Buster running the python3 sdk
That includes some patches around PPP and while it worked for our testing it would be nice to see if it might fix your problem. If not we will have to dig more into psutil but one would hope that library would terminate sessions like its supposed to.
I did try to run my script after the first step to confirm it removed the module and it did complain that it didn’t exist. After all the steps I was able to run the script again with the same result
Let me know if I am on the right track or if I botched that install.
Just kidding its hologram-python/develop, not development on checkout.
That worked and seemed to close the PPP session between loops!
Now when it goes to connect the second time it throws this traceback and leaves a PPP session open. My script has a 60 second delay between loops at the moment. (Edit) Also Tried with a 900 second delay.
Traceback (most recent call last):
File “nova-send-via-http.py”, line 73, in
hologram.network.connect(timeout=300)
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py”, line 77, in connect
self.__configure_routing()
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py”, line 170, in __configure_routing
self._route.add(‘10.176.0.0/16’, self.localIPAddress)
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Route.py”, line 61, in add
gateway=gateway)
File “/usr/local/lib/python3.7/dist-packages/pyroute2/iproute/linux.py”, line 1861, in route
callback=callback)
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 373, in nlm_request
return tuple(self._genlm_request(*argv, **kwarg))
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 870, in nlm_request
callback=callback):
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 376, in get
return tuple(self._genlm_get(*argv, **kwarg))
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 707, in get
raise msg[‘header’][‘error’]
pyroute2.netlink.exceptions.NetlinkError: (101, ‘Network is unreachable’)
hmm it doesnt look like we clean up the routing so maybe its throwing an error when trying to add the same route again. Thats my hunch. Will make a patch and let you know when its ready so you can test it.
Now it leaves the ppp session open (not defunct) and fails with the following traceback:
Traceback (most recent call last):
File “nova-send-via-http.py”, line 101, in
hologram.network.disconnect()
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py”, line 94, in disconnect
self.__remove_routing()
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py”, line 182, in __remove_routing
self._route.delete(‘10.176.0.0/16’, self.localIPAddress)
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Route.py”, line 72, in delete
gateway=gateway)
File “/usr/local/lib/python3.7/dist-packages/pyroute2/iproute/linux.py”, line 1861, in route
callback=callback)
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 373, in nlm_request
return tuple(self._genlm_request(*argv, **kwarg))
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 870, in nlm_request
callback=callback):
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 376, in get
return tuple(self._genlm_get(*argv, **kwarg))
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 707, in get
raise msg[‘header’][‘error’]
pyroute2.netlink.exceptions.NetlinkError: (3, ‘No such process’)
Ended back up here again. I was just testing so I’m not in a hurry and I’m always glad to help!
I made sure that the try statement you added on line 70 was there after I did my pull and then reinstalled from that build.
Traceback (most recent call last):
File “nova-send-via-http.py”, line 77, in
hologram.network.connect(timeout=300)
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py”, line 78, in connect
self.__configure_routing()
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py”, line 174, in __configure_routing
self._route.add(‘10.176.0.0/16’, self.localIPAddress)
File “/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Route.py”, line 61, in add
gateway=gateway)
File “/usr/local/lib/python3.7/dist-packages/pyroute2/iproute/linux.py”, line 1861, in route
callback=callback)
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 373, in nlm_request
return tuple(self._genlm_request(*argv, **kwarg))
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 870, in nlm_request
callback=callback):
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 376, in get
return tuple(self._genlm_get(*argv, **kwarg))
File “/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py”, line 707, in get
raise msg[‘header’][‘error’]
pyroute2.netlink.exceptions.NetlinkError: (101, ‘Network is unreachable’)
hmm ok i uploaded another patch, it feels like pyroute isn’t tearing down the routes with the delete so we’ll just assume if the routes have been setup once they haven’t been taken down.
Thats probably not a safe assumption to make but it gives me something to test against at least.
I get a similar trackback, but it does kill the pppd session! On the second loop through it also successfully starts another session before it bombs out. This is with a 120 second delay between iterations of the loop.
Traceback (most recent call last):
File "nova-send-via-http.py", line 77, in <module>
hologram.network.connect(timeout=300)
File "/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py", line 78, in connect
self.__configure_routing()
File "/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Cellular.py", line 174, in __configure_routing
self._route.add('10.176.0.0/16', self.localIPAddress)
File "/usr/local/lib/python3.7/dist-packages/hologram_python-0.9.0-py3.7.egg/Hologram/Network/Route.py", line 61, in add
gateway=gateway)
File "/usr/local/lib/python3.7/dist-packages/pyroute2/iproute/linux.py", line 1861, in route
callback=callback)
File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 373, in nlm_request
return tuple(self._genlm_request(*argv, **kwarg))
File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 870, in nlm_request
callback=callback):
File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 376, in get
return tuple(self._genlm_get(*argv, **kwarg))
File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 707, in get
raise msg['header']['error']
pyroute2.netlink.exceptions.NetlinkError: (101, 'Network is unreachable')
pi@tracker03:~ $ sudo ps -A | grep ppp
31325 pts/0 00:00:00 pppd
pi@tracker03:~ $ sudo ps -A | grep ppp
pi@tracker03:~ $ sudo ps -A | grep ppp
pi@tracker03:~ $ sudo ps -A | grep ppp
pi@tracker03:~ $ sudo ps -A | grep ppp
31497 pts/0 00:00:00 pppd