Connect following disconnect fails


#1

I’m using the python SDK to establish a connection with the hologram nova modem. Everything works well, but occasionally the connection is lost. When connection is lost, I would like to kill the existing PPP session and loop until a new one is created successfully. However, calling disconnect to ensure the previous session is disconnected, followed by connect, yields the message “Existing PPP session(s) are established by pid(s) [14158]. Please close/kill these processes first.” How can I correctly kill the previous session in the python script? Also how can I find the process id so I can kill the session with a subprocess call if necessary?

I have also gotten a network unreachable error on the second connection attempt when the initial attempt fails but doesn’t crash with the existence error.

Thanks for the help


#2

I think that’s a bug in our disconnect function. You can try doing the CLI version of that instead hologram network disconnect which will just kill every pppd process it finds.
You can copy the underlying code from here if you want: https://github.com/hologram-io/hologram-python/blob/master/scripts/hologram_network.py#L31


#3

Thanks for the quick response!

That makes sense. I copied the code and am now able to successfully kill the process, but the Modem doesn’t seem to know. The error I’m getting is in Hologram/Network/Modem/ModemMode/PPP on _enforce_no_existing_ppp_session. The pid it requests that I kill is the one I just killed using the code you linked.

I’m connecting withe the HologramCloud class, so I’m not sure how to access the Modem directly. What can I do to clear the Modem’s ppp_session?


#4

After reading through the repo I see that I can clear the process by calling hologram.network.disconnect() or alternatively by referencing hologram.network.modem.disconnect() directly. Now, most of the time I can loop until hologram.network.connect() returns true, which is great! However, occasionally the program seems to crash in the connect with the error:

pyroute2.netlink.exceptions.NetlinkError: (101, ‘Network is unreachable’)

Why would this happen sometimes, instead of just returning false so I can reattempt connection?