So we tried out the stack on a Raspberry Pi running Stretch.
The gateway-bridge runs fine without error and the lora-app-server seems to do as well.
But the loraserver randomly crash at startup everytime. It appears to be random according to the log files. The connection to postgres, redis and MQTT is double and triple cheched. In the log it more often crash after applying migrations but the migrations are done correct upon inspection of the database.
Could you try to start LoRa Server manually, it looks like the error is not in your logs? Trying to start LoRa Server manually might give you more information. The easiest is to use the commands below:
# set the loraserver configuration
set -a
source /etc/default/loraserver
# start loraserver
loraserver
I have edited the /etc/default/lora-app-server and /etc/default/loraserver on the remote server after the install - and replaced the null entries for the secrets with the original ones from the vagrant.yml file.
Running the server manually now results in this:
INFO[0000] starting LoRa Server band=âEU_863_870â docs=âhttps://docs.loraserver.io/â net_id=010203 version=0.21.0
INFO[0000] setup redis connection pool url=âredis://localhost:6379â
INFO[0000] connecting to postgresql
INFO[0000] backend/gateway: connecting to mqtt broker server=âtcp://localhost:1883â
ERRO[0000] backend/gateway: connecting to mqtt broker failed, will retry in 2s: Network Error : dial tcp 127.0.0.1:1883: getsockopt: connection refused
ERRO[0002] backend/gateway: connecting to mqtt broker failed, will retry in 2s: Network Error : dial tcp 127.0.0.1:1883: getsockopt: connection refused
Looking at Mosquitto - gives me this:
1510256857: mosquitto version 1.4.8 (build date Mon, 26 Jun 2017 09:31:02 +0100) starting
1510256857: Config loaded from /etc/mosquitto/mosquitto.conf.
1510256857: *** auth-plug: startup
1510256857: ** Configured order: files,postgres
1510256857: }}}} POSTGRES
1510256857: HERE: select count(*) from âuserâ where username = $1 and is_admin = true
1510256857: HERE: select distinct âapplication/â || a.id || â/node/+/+â from âuserâ u left join organization_user ou on u.id = ou.user_id left join organization o on o.id = ou.organization_id left join application_user au on u.id = au.user_id left join application a on au.application_id = a.id or a.organization_id = o.id left join node n on a.id = n.application_id where a.id is not null and u.username = $1 and $2 = $2
It seems like Mosquitto should be running - unless the Postgres stuff is failing. (Not familiar with this sql server)
However - Mosquitto isnât running - so that breaks everything.
Yes,
I had done a âgit pullâ prior to the installation attempt and updated my local copy of the repo.
It does look like PSQL wasnât running in time when my instance booted - and âsudo systemctl restart mosquittoâ seems to have fixed things.
I say seems since even though it appears it should accepting connections on 443 (https)
Nov 10 11:27:12 ip-172-31-25-123 lora-app-server[1362]: time=â2017-11-10T11:27:12Zâ level=info msg=âgwmigrate: migrating gateway data from LoRa Serverâ
Nov 10 11:27:12 ip-172-31-25-123 lora-app-server[1362]: time=â2017-11-10T11:27:12Zâ level=info msg=âstarting application-server apiâ bind=â0.0.0.0:8001â ca-cert= tls-cert= tls-key=
Nov 10 11:27:12 ip-172-31-25-123 lora-app-server[1362]: time=â2017-11-10T11:27:12Zâ level=info msg=âstarting client api serverâ bind=â0.0.0.0:443â tls-cert="/etc/lora-app-server/certs/http.pem" tls-key="/etc/lora-app-server/certs/http-key.pem"
Nov 10 11:27:12 ip-172-31-25-123 lora-app-server[1362]: time=â2017-11-10T11:27:12Zâ level=info msg=âregistering rest api handler and documentation endpointâ path="/api"
Nov 10 11:27:12 ip-172-31-25-123 lora-gateway-bridge[1307]: time=â2017-11-10T11:27:12Zâ level=info msg=âbackend: connecting to mqtt brokerâ server=âtcp://127.0.0.1:1883â
Nov 10 11:27:12 ip-172-31-25-123 lora-gateway-bridge[1307]: time=â2017-11-10T11:27:12Zâ level=info msg=âgateway: starting gateway udp listenerâ addr=0.0.0.0:1700
Nov 10 11:27:12 ip-172-31-25-123 lora-gateway-bridge[1307]: time=â2017-11-10T11:27:12Zâ level=info msg=âbackend: connected to mqtt brokerâ
Connection attempts to https via my browser just timeout eventually.
I am using the same security settings for this server as another one on AWS - and the iptables shouldnât be a factor since I have 443 wide open iptables wise (relying on AWS security settings)
Hi @brocaar I meet the same error,when I try to compile from the source
make build
cd build
./loraserver
FATA[0000] NetID parse error: lorawan: exactly 3 bytes are expected
when I run make test
Given a clean database and api instance ERRO[0000] ping database error, will retry in 2s: pq: password authentication failed for user âryanâ
ERRO[0002] ping database error, will retry in 2s: pq: password authentication failed for user âryanâ
ERRO[0004] ping database error, will retry in 2s: pq: password authentication failed for user âryanâ
âŚ
I have set the GW_SERVER_JWT_SECRET in /github.com/brocaar/loraserver/packaging/deb/default ,but it doesnât work
When you start loarserver manually, you need to explicitly set either the environment variables or the cli flags. Normally, the service would do this for you (if you check packaging/deb/init.sh, youâll see that the default file is getting set) on sudo service loraserver start, but manually you need to do it. This can be done with:
set -a
source /loraserver/packaging/deb/default (or /path/to/file)
./loraserver
No problem. It can be a pain remembering to source the env vars before starting the binaries, so if itâs of any help, thereâs a dropdown terminal called Guake thatâll let you hook an init script before launching (and a lot more). Of course, you could do the same with an init script that launches 5 terminals, but I prefer using Guake.
I usually work with 5 tabs, for loraserver, lora-app-server, npm, some simulation scripts and a multi-purpose one (connecting to psql, ssh-ing to a remote server, etc.). So I just adapted a script that on startup opens 5 tabs, cds to the proper directories and executes anything else necessary, like setting the env vars. Iâll leave it here as an example in case anyone wants to set something similar:
#!/bin/bash
/usr/bin/guake &
sleep 2 # let main guake process start and initialize D-Bus session
guake -r "Appserver" -e "cd /home/iegomez/go/src/github.com/brocaar/lora-app-server/ && set -a && source ../appserver_env_vars"
guake -n " " -r "Loraserver" -e "cd /home/iegomez/go/src/github.com/brocaar/loraserver/ && set -a && source ../loraserver_env_vars"
guake -n " " -r "React UI" -e "cd /home/iegomez/go/src/github.com/brocaar/lora-app-server/ui"
guake -n " " -r "Lora scripts" -e "cd /home/iegomez/go/src/github.com/lora-scripts/"
guake -n " " -r "Terminal" -e "cd /home/iegomez"
guake -s 0
An alternative could also be https://direnv.net. It allows you to create .envrc files in each directory with the environment variables that must be set within the context of that directory.