|
| 1 | +--- |
| 2 | +title: Debugging |
| 3 | +menu: |
| 4 | + main: |
| 5 | + parent: install |
| 6 | + weight: 6 |
| 7 | +--- |
| 8 | + |
| 9 | +## Debugging |
| 10 | + |
| 11 | +The follwing steps can be used to debug any LoRa Gateway Bridge related issues. |
| 12 | + |
| 13 | +### Receiving MQTT messages |
| 14 | + |
| 15 | +To validate that the LoRa Gateway Bridge is publishing LoRa frames to the |
| 16 | +MQTT broker, you can subscribe to the `gateway/+/rx` MQTT topic. When using |
| 17 | +the `mosquitto_sub` utility, you can execute the following command: |
| 18 | + |
| 19 | +```bash |
| 20 | +mosquitto_sub -v -t "gateway/+/rx" |
| 21 | +``` |
| 22 | + |
| 23 | +Of course you will only see data when the gateway is receiving LoRa frames. |
| 24 | +Make sure that your node is sending some data. |
| 25 | + |
| 26 | +When you don't see any frames appearing, this could be caused by the following issues: |
| 27 | + |
| 28 | +* LoRa Gateway Bridge does not receive data from the packet-forwarder |
| 29 | +* The MQTT credentials / authorizations are invalid (the user is not authorized |
| 30 | + to subscribe to the MQTT topic) |
| 31 | + |
| 32 | +### Is LoRa Gateway Bridge receiving data |
| 33 | + |
| 34 | +To validate that the LoRa Gateway Bridge is receiving, you can take a look |
| 35 | +at the LoRa Gateway Bridge logs. How to retrieve the logs depends on how you |
| 36 | +installed the LoRa Gateway Bridge. When you followed the [Debian / Ubuntu]({{<ref "install/debian.md">}}) |
| 37 | +installation steps, this is either: |
| 38 | + |
| 39 | +* `journalctl -f -n 100 -u lora-gateway-bridge` |
| 40 | +* `tail -f -n 100 /var/log/lora-gateway-bridge/lora-gateway-bridge.log` |
| 41 | + |
| 42 | +With an interval of a couple of seconds, the following lines should appear (`PullData` / `PullACK`): |
| 43 | + |
| 44 | +```text |
| 45 | +level=info msg="gateway: received udp packet from gateway" addr=127.0.0.1:34268 protocol_version=2 type=PullData |
| 46 | +level=info msg="gateway: sending udp packet to gateway" addr=127.0.0.1:34268 protocol_version=2 type=PullACK |
| 47 | +level=info msg="gateway: received udp packet from gateway" addr=127.0.0.1:34268 protocol_version=2 type=PullData |
| 48 | +level=info msg="gateway: sending udp packet to gateway" addr=127.0.0.1:34268 protocol_version=2 type=PullACK |
| 49 | +level=info msg="gateway: received udp packet from gateway" addr=127.0.0.1:43827 protocol_version=2 type=PushData |
| 50 | +level=info msg="gateway: sending udp packet to gateway" addr=127.0.0.1:43827 protocol_version=2 type=PushACK |
| 51 | +``` |
| 52 | + |
| 53 | +The packet-forwarder sends every couple of seconds a ping (`PullData`) to which |
| 54 | +the LoRa Gateway Bridge must respond (`PullACK`). |
| 55 | + |
| 56 | +When you don't see these logs, this could be caused by the following issues: |
| 57 | + |
| 58 | +* The packet-forwarder is not running |
| 59 | +* The packet-forwarder is forwarding to a different host / port |
| 60 | +* Firewall / NAT issue (in case the packet-forwarder and LoRa Gateway Bridge are not installed on the same device) |
| 61 | + |
| 62 | +When you do see these logs, but you don't receive any MQTT messages, this could |
| 63 | +be caused by: |
| 64 | + |
| 65 | +* The MQTT user is not authorized to publish data to the MQTT topic or, the MQTT |
| 66 | + user for subscribing is not authorized to subscribe to the MQTT topic. |
| 67 | +* The node is sending on a frequency that the packet-forwarder is not |
| 68 | + configured for. |
| 69 | + |
| 70 | +### Is the packet-forwarder running |
| 71 | + |
| 72 | +To validate that the packet-forwarder is running, you could execute the |
| 73 | +following command on your gateway: |
| 74 | + |
| 75 | +```bash |
| 76 | +# when the LoRa Gateway Bridge is running on the same device, add -i lo |
| 77 | +sudo tcpdump -AUq -i lo port 1700 |
| 78 | + |
| 79 | +# when the LoRa Gateway Bridge is running somewhere else |
| 80 | +sudo tcpdump -AUq port 1700 |
| 81 | +``` |
| 82 | + |
| 83 | +This should output something like: |
| 84 | + |
| 85 | +```text |
| 86 | +11:42:00.114726 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 87 | +E..(..@.@."................'.....UZ..... |
| 88 | +11:42:00.130292 IP localhost.1700 > localhost.34268: UDP, length 4 |
| 89 | +E.. ..@.@."..................... |
| 90 | +11:42:10.204723 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 91 | +E..(.&@.@..................'.x...UZ..... |
| 92 | +11:42:10.206503 IP localhost.1700 > localhost.34268: UDP, length 4 |
| 93 | +E.. .'@.@....................x.. |
| 94 | +11:42:10.968420 IP localhost.43827 > localhost.1700: UDP, length 113 |
| 95 | +E....h@.@............3...y.......UZ.....{"stat":{"time":"2017-09-11 11:42:10 GMT","rxnb":0,"rxok":0,"rxfw":0,"ackr":100.0,"dwnb":0,"txnb":0}} |
| 96 | +11:42:10.970702 IP localhost.1700 > localhost.43827: UDP, length 4 |
| 97 | +E.. .i@.@..b...........3........ |
| 98 | +11:42:20.284752 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 99 | +E..(..@.@..................'.....UZ..... |
| 100 | +11:42:20.289256 IP localhost.1700 > localhost.34268: UDP, length 4 |
| 101 | +E.. ..@.@....................... |
| 102 | +11:42:30.364780 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 103 | +E..( .@.@..................'.S7..UZ..... |
| 104 | +11:42:30.366310 IP localhost.1700 > localhost.34268: UDP, length 4 |
| 105 | +E.. .@.@....................S7. |
| 106 | +``` |
| 107 | + |
| 108 | +What we see in this log: |
| 109 | + |
| 110 | +* `localhost.34268 > localhost.1700`: packet sent from the packet-forwarder to the LoRa Gateway Bridge |
| 111 | +* `localhost.1700 > localhost.34268`: packet sent from the LoRa Gateway Bridge to the packet-forwarder |
| 112 | + |
| 113 | +A log example where the packet-forwarder is sending data, but not receiving |
| 114 | +any data (caused by a firewall / NAT issue?): |
| 115 | + |
| 116 | +```text |
| 117 | +11:47:22.724729 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 118 | +E..([.@.@..................'.....UZ..... |
| 119 | +11:47:32.804724 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 120 | +E..(].@.@..................'.!...UZ..... |
| 121 | +11:47:40.964220 IP localhost.43827 > localhost.1700: UDP, length 113 |
| 122 | +E...`/@.@............3...y...s...UZ.....{"stat":{"time":"2017-09-11 11:47:40 GMT","rxnb":0,"rxok":0,"rxfw":0,"ackr":100.0,"dwnb":0,"txnb":0}} |
| 123 | +11:47:42.884727 IP localhost.34268 > localhost.1700: UDP, length 12 |
| 124 | +E..(`f@.@..\...............'.-C..UZ..... |
| 125 | +``` |
| 126 | + |
| 127 | +When you don't see any of these, this could be caused by the following issues: |
| 128 | + |
| 129 | +* The packet-forwarder is not running |
| 130 | +* The packet-forwarder is forwarding to a different host / port |
| 131 | + |
| 132 | +### Where is the packet-forwarder sending data to |
| 133 | + |
| 134 | +Inspect the `local_conf.json` of the packet-forwarder running on your gateway. |
| 135 | +You might need to refer to your gateway manual to find out where you can locate |
| 136 | +this file. This file could contain the following content: |
| 137 | + |
| 138 | +```json |
| 139 | +{ |
| 140 | + "gateway_conf": { |
| 141 | + ... |
| 142 | + "serv_port_down": 1700, |
| 143 | + "serv_port_up": 1700, |
| 144 | + "server_address": "localhost", |
| 145 | + ... |
| 146 | + } |
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +What we learn from this file is that: |
| 151 | + |
| 152 | +* It uses port `1700` (default port used by LoRa Gateway Bridge) |
| 153 | +* It sends data to `localhost` (when LoRa Gateway Bridge is installed on the same device) |
| 154 | + |
| 155 | +Make sure the ports and `server_address` are correct. In case LoRa Gateway |
| 156 | +Bridge is not running on the same device, you need to replace this with the |
| 157 | +correct hostname or IP of your LoRa Gateway Bridge instance. After making any |
| 158 | +changes, don't forget to restart the packet-forwarder. |
| 159 | + |
| 160 | +See [https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd](https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd) |
| 161 | +for more information about the packet-forwarder. |
0 commit comments