jpmeijers / ttn-resin-gateway-rpi

81 stars 41 forks source link

ttn router mqtt_address may omit mqtt protocl from url #12

Closed Karlpietsch closed 6 years ago

Karlpietsch commented 6 years ago

with certain router configurations such as for australia's "meshed-au" TTN omits the "mqtt://" prefix on the mqtt_address property of config response, this causes python urlparse function to fail and router hostname ends up null.

eg:

"router": { "address": "thethings.meshed.com.au:1901", "id": "meshed-router", "mqtt_address": "thethings.meshed.com.au:1882" }

rather than

"router": { "address": "eu.thethings.network:1901", "id": "ttn-router-eu", "mqtt_address": "mqtts://bridge.eu.thethings.network" }

jpmeijers commented 6 years ago

Oh dammit. This was originally also a problem and URLparse was a nice fix. Need to find a better solution then.

We can test of the string starts with mqtt, and add it if it doesn't, but that's a hack.

This looks like an issue with the setup of the router and it not keeping to the specifications. Shouldn't this be fixed on the router's side?

Karlpietsch commented 6 years ago

yes ttn should be correctly returning a full URI, I did also realise that thethigns.meshed.com.au also uses a different port so that will need to be taken into account even if the URI prefix is fixed on TTN config side.

philwilkinson40 commented 6 years ago

upfront apologies if this is not the correct way to discuss this in GitHub, its my first time posting... I am not sure if this is a new issue (or just the same issue#12) from the error messages. The error below is returned on Resin.io using a RAK backplate gateway, AU915 frequency initially with meshed-router, but then subsequently with ttn-router-jp, returns the same error:

25.03.18 14:00:12 (+0800)  main  /sbin/udevd
25.03.18 14:00:13 (+0800)  main  *** Resin Machine Info:
25.03.18 14:00:13 (+0800)  main  *** Type: None
25.03.18 14:00:13 (+0800)  main  *** Arch: None
25.03.18 14:00:13 (+0800)  main  *******************
25.03.18 14:00:13 (+0800)  main  *** Configuration:
25.03.18 14:00:13 (+0800)  main  *******************
25.03.18 14:00:13 (+0800)  main  *******************
25.03.18 14:00:13 (+0800)  main  *** Fetching config from TTN account server
25.03.18 14:00:13 (+0800)  main  *******************
25.03.18 14:00:15 (+0800)  main  Gateway ID:    floreat2
25.03.18 14:00:15 (+0800)  main  Gateway Key:   ttn-account-v2.E.......
25.03.18 14:00:15 (+0800)  main  Frequency plan:                AU_915_928
25.03.18 14:00:15 (+0800)  main  Frequency plan url:    https://account.thethingsnetwork.org/api/v2/frequency-plans/AU_915_928
25.03.18 14:00:15 (+0800)  main  Gateway description:   Floreat_Forwarder_2
25.03.18 14:00:15 (+0800)  main  Gateway placement:     indoor
25.03.18 14:00:15 (+0800)  main  Traceback (most recent call last):
25.03.18 14:00:15 (+0800)  main    File "/opt/ttn-gateway/run.py", line 137, in <module>
25.03.18 14:00:15 (+0800)  main      print ("Router:\t\t\t"+router)
25.03.18 14:00:15 (+0800)  main  TypeError: cannot concatenate 'str' and'NoneType' objects
25.03.18 14:00:16 (+0800) Service exited 'main sha256:........'