Open tho-wa opened 5 years ago
Created pull request: https://github.com/jpmeijers/ttn-resin-gateway-rpi/pull/23
Ahh good catch. I am experiencing this same issue after a power outage where the gateway and container will start up before my ADSL connection had time to connect. Causing the same timeout. It would be a better solution to get the fetching config step time out and crash so that the container can start up again - rather than adding a static delay.
Sure, you can just modify my pull request. Thanks.
Will update with loop that retries until connection is ready.
It seems like our try-except in a loop prevents the script from crashing, but it does not solve the root cause. I get the following output:
04.05.19 16:16:01 (+0200) main Unable to fetch configuration from TTN. Is the TTN API reachable from gateway? Are your GW_ID and GW_KEY correct? Retry in 30s
04.05.19 16:16:32 (+0200) main Unable to fetch configuration from TTN. Is the TTN API reachable from gateway? Are your GW_ID and GW_KEY correct? Retry in 30s
04.05.19 16:17:03 (+0200) main Unable to fetch configuration from TTN. Is the TTN API reachable from gateway? Are your GW_ID and GW_KEY correct? Retry in 30s
04.05.19 16:17:34 (+0200) main Unable to fetch configuration from TTN. Is the TTN API reachable from gateway? Are your GW_ID and GW_KEY correct? Retry in 30s
And in the meantime I was able to do a apt update, install telnet, and check that I can telnet to port 80 and 443 on the account server. So the issue is not a network one. I have added a print(err) inside the except now to try and see what is causing an exception. Will have to wait for this to happen again.
I added a catch statement to print out the error that happens:
18.06.19 11:34:41 (+0200) main HTTP Error 404: Not Found
18.06.19 11:34:41 (+0200) main Unable to fetch configuration from TTN. Is the TTN API reachable from gateway? Are your GW_ID and GW_KEY correct? Retry in 30s
So it's a 404 Not Found. But when I use wget inside the container to GET the same URL it does work. So for some reason the urllib2 Python library gets stuck. Next option might be to switch to the Requests library.
If you use cellular, container can be startet before cellular connection is ready. Because "Fetching config" has only one retry after 30sec, the application will never go online. You can bring it only online by manually restarting the container later. Would it be possible to extend retry time maybe for 5minutes? thanks.