gotthardp / lorawan-server

Compact server for private LoRaWAN networks
https://gotthardp.github.io/lorawan-server
MIT License
956 stars 329 forks source link

Gateway never connects to server #435

Closed NicoHell1 closed 6 years ago

NicoHell1 commented 6 years ago

Hi, I am currently trying to run the server with a Semtech gateway (picoCell) but I have some connection issues. I launched the server, set the UDP port for listening in sys.config (used the same port in the packet forwarder application provided by Semtech). I also registered the gateway on the admin page but the gateway never connects and I cannot see why. I managed to get it to work well on another computer (with same parameters, same gateway) so I do not understand why it does not work now. The weird part is that I think that the gateway is receiving the ACK (see screenshot) but it is always shown as disconnected on the admin page. I do not know if the problem comes from the server or from the configuration or from the packet forwarder application. I also join the logs from the server. capture crash.log debug.log error.log Thank you for your help

gotthardp commented 6 years ago

The logs show multiple restarts of the server. The first few show that a gateway did connect, but after the last reboot no gateway did connect. Right?

The gateway is shown as disconnected if it does not send the "stat" object regularily (see https://github.com/Lora-net/packet_forwarder/blob/master/PROTOCOL.TXT#L197). I've already seen gateways not doing so. Your gateway log shows only "rxpk". Did the gateway ever sent a "stat"? If not, could you figure out why?

NicoHell1 commented 6 years ago

Thank you for your answer, indeed I restarted several times the server in order to change the configs, I think that the gateway did connect but it did when I launched the application Packet_Util_Tx provided by Semtech and when I started this application, the gateway connected but all acks were lost, I did not understand this either, the "packet forwarder" application never managed to connect the gateway but the other application did. It seems that the gateway sends the stat object, i ran the packet forwarder again to verify capture2

gotthardp commented 6 years ago

How about the time on the gateway and the server? The gateway looks OK; does the server have the same time-- and the same timezone?

NicoHell1 commented 6 years ago

It seems that the gateway has indeed a problem for time, I checked again and it sends its stat object with a different time (2 hours earlier approx), it is 11:20 here and the gateway sends its stat object with a time set to approx 9AM, do you have any idea why ? The system time is set to the right time and the right timezone

gotthardp commented 6 years ago

The gateway sends GMT. For example CEST is GMT+2. https://www.worldtimebuddy.com/cest-to-gmt-converter

NicoHell1 commented 6 years ago

Well I tried changing the timezone on the computer and set it to UTC so the gateway & the server are set to the same time but that did not work as well, maybe the reason why the gateway does not connect lies here but I did not managed to resolve that issue yet

gotthardp commented 6 years ago

If you open the Gateway in the web-admin, what do you see as "Last Alive" and "Last Report" on the "Status" tab?

NicoHell1 commented 6 years ago

capture3

gotthardp commented 6 years ago

That's yesterday. The server is running on the same machine as the packet_forwarder? Could the gateway be connecting to some other server?

NicoHell1 commented 6 years ago

Yes indeed that was yesterday and yes the server is running on the same machine as the packet forwarder but I think that it is not possible to connect the gateway to another server (the ports are closed by network admin), I can only run the server on localhost

NicoHell1 commented 6 years ago

I tried again on the PC I used earlier and it worked, even if the gateway & the server seem to be configured in different timezones (gateway sends stat object with GMT, server is configured like the machine on UTC+1 Paris timezone, summer hour so there is a 2 hour shift between them), I just do not understand why it does not work on the other PC, I might try again tomorrow just to see if there is a difference

NicoHell1 commented 6 years ago

So I tried again and I still have the issue unfortunately. Same as yesterday, gateway does not connect with packet forwarder, connects to server with the application Packet Util Tx but all acks are lost capture capture2

gotthardp commented 6 years ago

I believe you set the correct server port, right?

NicoHell1 commented 6 years ago

Yes, in packet forwarder same for port up & port down, the same port in sys.config for the lorawan server, maybe the problem comes from the computer itself because on my other machine I have no particular issue with the same configs

gotthardp commented 6 years ago

There used to be a weird connectivity problem when the server hostname and IP were not properly configured. What is displayed if you do hostname --short and hostname --long? What does your ifconfig and netstat -tlp (with server and packet_forwarder started) say?

NicoHell1 commented 6 years ago

I cannot tell you for now, I will try that tomorrow and keep you informed

NicoHell1 commented 6 years ago

So I tried on another machine, seems that it did not work though, apparently it works only on the first PC I used, cannot figure out why. The screenshots below are the results of netstat for TCP and UDP on the new machine which seems to have the same issue (the port configured for packet forwarder & network server is 1680) capture captureudp

NicoHell1 commented 6 years ago

I believe I found the issue, it was not related to the 1680 port but the 8080. I added a new rule for the firewall enabling the connection on port 8080 for TCP & UDP (just to be sure) and it seems to work a lot better now

gotthardp commented 6 years ago

So does it work now? Can we close this issue?

NicoHell1 commented 6 years ago

Yes indeed, it did work on the third machine so I guess the issue can be closed Thank you very much for you help