kersing / packet_forwarder

Multi protocol packet forwarder supporting the TTN gateway-connector protocol.
Other
85 stars 56 forks source link

Program killed when internet is not available #19

Closed hilt0n closed 6 years ago

hilt0n commented 6 years ago

Following the standard packet-forwarder from Semtech or the poly-packet-forwarder from TTN, when the forwarder is started and no internet connection is up on the target, it will result in a exit_failure. This is particularly the case when for example a gateway is connected to a 3/4G access point which boot at the same time.

I already modified these 2 forwarders to manage this use case and simply wait for internet to be available. It's cleary a matter of opinion but I prefer to manage this case directly in the packet forwarder instead of adding a script which would have to restart the packet-forwarder multiple time until the connection is available.

I don't know your opinion about this point but if you are interested in managing it directly in your packet-forwarder, I would be pleased to discuss about it with you how we can integrate it, let me know.

kersing commented 6 years ago

The startup sequence of the gateway should take care of the internet connection. For 'full' Linux systems with systemd this can be achieved by making the service dependent on the internet connection. For other systems this can be done in the startup script for the forwarder.

BTW, if you are using the TTN transport you can make a connection with "critical": false, this should allow the packet forwarder to start and connect later on (with retries if the connection fails).

hilt0n commented 6 years ago

I agree with you but without systemd, it's not so clean... In addition, I don't think any parameter could change that since the exit_failure comes from the call to getaddrinfo with returns an error if no connection is detected.

It's not a problem, I will integrite myself in your code but if you want to integrate it directly in your repo, let me know.

kersing commented 6 years ago

That call is not being used for TTN transport when initializing the connection. So the mentioned parameter should work just fine.

kersing commented 6 years ago

I will not change the behavior of the packet forwarder. As stated before the system should have an internet connection in place before starting the packet forwarder. TTN strongly suggests to download the most recent global_conf.json file for the region when starting the packet forwarder, this needs to be done before start of the forwarder and requires an internet connection as well.