Installation of the LoRaServer on Raspberry pi 3 B

Thank you very much for your patience and help.

LoRa App Server v1.0.1 has been released :slight_smile:

okay. Let me get back to the installation, I’ll keep you posted.

I should get the version v1.0.1 under the command : sudo apt install lora-app-server.:sunglasses:.I just to make sure i don’t run into those errors anymore. Thanks once more.

I removed the lora-app-server.toml file with the command you provided in your response. Then I tried reinstalling it. The installation process returned this logs bellow, But when i go the path /ect/lora-app-server/ the file is not there and the application server can still be started. To my understanding, it is installed somewhere else on my system. How can I get rid of it completely, giving that I don’t know where it is installed. Yes I have tried, apt-get remove lora-app-server.toml but is does not find any file to remove.

pi@raspberrypi:/etc $ sudo apt install lora-app-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
lora-app-server is already the newest version (1.0.0).
0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.

The reinstallation worked.

Running into the same error. As the logs bellow can show that the TLS is empty. I can assume from that it refers to the problem you described earlier today. But I did reinstall the lora-app-server but the same issues. I guess, I will have to insert these values manually. Thanks.

`-- Logs begin at Thu 2016-11-03 18:16:43 CET, end at Wed 2018-05-30 13:24:00 CEST. –
May 30 13:19:14 raspberrypi systemd[1]: Started LoRa App Server.
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“starting LoRa App Server” docs=“https://www.loraserver.io/” version=1.0.1
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“connecting to postgresql”
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“setup redis connection pool”
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg="handler/mqtt: TLS config is empty"
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“handler/mqtt: connecting to mqtt broker” server=“tcp://localhost:1883”
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“applying database migrations”
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“handler/mqtt: connected to mqtt broker”
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“handler/mqtt: subscribing to tx topic” qos=0 topic=application/+/device/+/tx
May 30 13:19:16 raspberrypi lora-app-server[709]: time=“2018-05-30T13:19:16+02:00” level=info msg=“migrations applied” count=0
May 30 13:19:16 raspberrypi systemd[1]: lora-app-server.service: Main process exited, code=exited, status=1/FAILURE
May 30 13:19:16 raspberrypi systemd[1]: lora-app-server.service: Unit entered failed state.
May 30 13:19:16 raspberrypi systemd[1]: lora-app-server.service: Failed with result ‘exit-code’.
May 30 13:19:16 raspberrypi systemd[1]: lora-app-server.service: Service hold-off time over, scheduling restart.
May 30 13:19:16 raspberrypi systemd[1]: Stopped LoRa App Server.
May 30 13:19:16 raspberrypi systemd[1]: Started LoRa App Server.
May 30 13:19:16 raspberrypi lora-app-server[764]: time=“2018-05-30T13:19:16+02:00” level=info msg=“starting LoRa App Server” docs=“https://www.loraserver.io/” version=1.0.1
May 30 13:19:16 raspberrypi lora-app-server[764]: time=“2018-05-30T13:19:16+02:00” level=info msg=“connecting to postgresql”
May 30 13:19:16 raspberrypi lora-app-server[764]: time=“2018-05-30T13:19:16+02:00” level=info msg=“setup redis connection pool”
May 30 13:19:16 raspberrypi lora-app-server[764]: time=“2018-05-30T13:19:16+02:00” level=info msg=“handler/mqtt: TLS config is empty”
May 30 13:19:16 raspberrypi lora-app-server[764]: time=“2018-05-30T13:19:16+02:00” level=info msg=“handler/mqtt: connecting to mqtt broker” server=“tcp://localhost:1883”
May 30 13:19:16 raspberrypi lora-app-server[764]: time=“2018-05-30T13:19:16+02:00” level=info msg=“applying database migrations”
lines 1-23

This is a more detailed version of the errors, Can you guys help identify what the problem is ?, please.
May 30 14:13:04 raspberrypi lora-app-server[863]: time=“2018-05-30T14:13:04+02:00” level=info msg=“migrations applied” count=0
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Main process exited, code=exited, status=1/FAILURE
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Unit entered failed state.
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Failed with result ‘exit-code’.
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Service hold-off time over, scheduling restart.
May 30 14:13:04 raspberrypi systemd[1]: Stopped LoRa App Server.
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Start request repeated too quickly.
May 30 14:13:04 raspberrypi systemd[1]: Failed to start LoRa App Server.
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Unit entered failed state.
May 30 14:13:04 raspberrypi systemd[1]: lora-app-server.service: Failed with result ‘exit-code’.

since the failure was on the lora-app-server.service, this is the content of the service file, maybe i am missing something.
[Unit]
Description=LoRa App Server
Documentation=https://docs.loraserver.io
Wants=network-online.target
After=network-online.target mosquitto.service redis.service postgresql.service

[Service]
User=appserver
Group=appserver
ExecStart=/usr/bin/lora-app-server
Restart=on-failure

[Install]
WantedBy=multi-user.target

I think the lora-app-server starts now. :sweat_smile: I get the following output. Now trying to connect on the web-interface.
– Logs begin at Thu 2016-11-03 18:16:43 CET. –
May 30 18:35:08 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:08+02:00” level=info msg=“handler/mqtt: TLS config is empty”
May 30 18:35:08 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:08+02:00” level=info msg=“handler/mqtt: connecting to mqtt broker” server=“tcp://localhost:1883”
May 30 18:35:08 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:08+02:00” level=info msg=“applying database migrations”
May 30 18:35:08 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:08+02:00” level=info msg=“handler/mqtt: connected to mqtt broker”
May 30 18:35:08 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:08+02:00” level=info msg=“handler/mqtt: subscribing to tx topic” qos=0 topic=application/+/device/+/tx
May 30 18:35:09 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:09+02:00” level=info msg=“migrations applied” count=0
May 30 18:35:09 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:09+02:00” level=info msg=“starting application-server api” bind=“0.0.0.0:8001” ca-cert= tls-cert= tls-key=
May 30 18:35:09 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:09+02:00” level=info msg=“starting join-server api” bind=“0.0.0.0:8003” ca_cert= tls_cert= tls_key=
May 30 18:35:09 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:09+02:00” level=info msg=“starting client api server” bind=“0.0.0.0:8080” tls-cert=/etc/lora-app-server/certs/http.pem tls-key=/etc/lora-app-server/certs/http-key.pem
May 30 18:35:09 raspberrypi lora-app-server[10491]: time=“2018-05-30T18:35:09+02:00” level=info msg=“registering rest api handler and documentation endpoint” path=/api
May 30 18:36:22 raspberrypi lora-app-server[10491]: 2018/05/30 18:36:22 http: TLS handshake error from 127.0.0.1:41058: tls: first record does not look like a TLS handshake
May 30 18:36:23 raspberrypi lora-app-server[10491]: 2018/05/30 18:36:23 http: TLS handshake error from 127.0.0.1:41060: tls: first record does not look like a TLS handshake
May 30 18:36:28 raspberrypi lora-app-server[10491]: 2018/05/30 18:36:28 http: TLS handshake error from 127.0.0.1:41062: tls: first record does not look like a TLS handshake
May 30 18:36:38 raspberrypi lora-app-server[10491]: 2018/05/30 18:36:38 http2: server: error reading preface from client 127.0.0.1:41066: read tcp 127.0.0.1:8080->127.0.0.1:41066: read: connection reset by peer
May 30 18:36:54 raspberrypi lora-app-server[10491]: 2018/05/30 18:36:54 http: TLS handshake error from 127.0.0.1:41068: tls: first record does not look like a TLS handshake

I managed to connect and login to the app-server web interface. But the page is blank. I can’t carry out any action on the interface. I am def missing something but I can’t tell what that is.

I can now connect and login to the application server, i also get the pages fully rendered.

Could you please share the steps that you took to solve your issues? That might be helpful for others when they are running into the same issue :slight_smile:

To solve the lora-app-server related failures, I had to change the value of my jwt_secret. Then it started working.

I am however facing another issue. I think my lora-app-server is not publishing the received data to the MQTT broker ( mosquitto). Thus, running the following commands return nothing:
mosquitto_sub -v -t “application/#” -h localhost -p 1883
mosquitto_sub -v -t “application/appId/#” -h localhost -p 1883 , with the numerical substitution for appId.
Can someone help with this?

I only saw this thread when I received the LoRa Server Forum Summary today. Here I am providing the complete instruction on installing LoRa Server on Raspberry Pi 3B. Hope it can help. It is an expansion of the quick install guide. It is written in a combination of Makefile and text instruction.

################################################################################################

https://www.loraserver.io/install/quick-install/

################################################################################################

################################################################################################

Install Requirements

################################################################################################
install_required:
sudo apt-get install mosquitto mosquitto-clients redis-server redis-tools

################################################################################################

Install PostgreSQL 9.6

Create a backports.list file in /etc/apt/sources.list.d containing

deb http://ftp.debian.org/debian jessie-backports main

################################################################################################
install_psql_9.6:
sudo apt-get install dirmngr
sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8B48AD6246925553
sudo gpg -a --export 8B48AD6246925553 | sudo apt-key add -
sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 7638D0442B90D010
sudo gpg -a --export 7638D0442B90D010 | sudo apt-key add -
sudo apt-get update
sudo apt-get -t jessie-backports install postgresql-9.6
sudo apt-get -t jessie-backports install postgresql-contrib-9.6
sudo apt-get -t jessie-backports install postgresql-doc-9.6

################################################################################################

Mosquitto Authentication

Create a password file for your mosquitto users, starting with a “root” user.

The “-c” parameter creates the new password file. The command will prompt for

a new password for the user.

################################################################################################
mosquitto_authentication:
sudo mosquitto_passwd -c /etc/mosquitto/pwd loraroot
sudo mosquitto_passwd /etc/mosquitto/pwd loragw
sudo mosquitto_passwd /etc/mosquitto/pwd loraserver
sudo mosquitto_passwd /etc/mosquitto/pwd loraappserver
sudo chmod 600 /etc/mosquitto/pwd

################################################################################################

Mosquitto Configuration

Edit /etc/mosquitto/conf.d/local.conf, Add the following lines:

allow_anonymous false

password_file /etc/mosquitto/pwd

################################################################################################

################################################################################################

PostgreSQL Databases and Users

Enter command: sudo -u postgres psql

Run following commands in psql command line

– set up the users and the passwords (note that it is important to use single quotes and a semicolon at the end!)

create role loraserver_as with login password ‘dbpassword’;

create role loraserver_ns with login password ‘dbpassword’;

– create the database for the servers

create database loraserver_as with owner loraserver_as;

create database loraserver_ns with owner loraserver_ns;

– exit psql

\q

################################################################################################

################################################################################################

Setup LoRa Server software repository

################################################################################################
setup_loraserver_repository:
sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 1CE2AFD36DBCCA00
sudo gpg -a --export 1CE2AFD36DBCCA00 | sudo apt-key add -
#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1CE2AFD36DBCCA00
sudo echo “deb https://repos.loraserver.io/ubuntu xenial testing” | sudo tee /etc/apt/sources.list.d/loraserver.list
sudo apt-get install apt-transport-https
sudo apt-get update

################################################################################################

Installing LoRa Gateway Bridge

################################################################################################
install_gwbridge:
sudo apt-get install lora-gateway-bridge
################################################################################################

Edit /etc/lora-gateway-bridge/lora-gateway-bridge.toml to change username and password

1. packet_forwarder.udp_bind - The interface and port on which the LoRa Gateway Bridge listens

for packets from your gateways. This should normally be 0.0.0.0:1700 to allow access on

all network interfaces. However, in the case of gateway and server sit on the same host

where the bridge only listens to one gateway, it should be changed to “127.0.0.1:1700”.

2. backend.mqtt.username and backend.mqtt.password - since the MQTT server is publicly

accessible (so LoRa Gateway Bridge instances can send data), it is best to have a username

and password for the server here. These credentials were the ones set up in the Mosquitto

authentication step.

################################################################################################

################################################################################################

Installing LoRa Server

################################################################################################
install_loraserver:
sudo apt-get install loraserver
################################################################################################

Edit /etc/loraserver/loraserver.toml

1. network_server.band.name - The ISM band to use. E.g. for US installations, use US_902_928.

2. postgresql.dsn - The URL to the postgres server. Add username:password@ to the URL. e.g.,

postgres://loraserver_ns:dbpassword@localhost/loraserver?sslmode=disable. Be careful with

this setting. It is easy to get wrong, and can produce a number of different error messages.

3. postgresql.automigrate - Leave this set to true, as it only takes a moment to run at server

startup, and ensures that database changes will always be applied with each upgrade.

4. network_server.gateway.backend.mqtt.username and

network_server.gateway.backend.mqtt.password - since the MQTT server is publicly accessible

(so LoRa Gateway Bridge instances can send data), it is best to have a username and

password for the server here. These credentials were the ones set up in the Mosquitto

authentication step.

5. network_server.gateway.stats.create_gateway_on_stats - creates a gateway record for the

gateway when stats are seen. Otherwise gateway data must be populated manually using the

LoRa App Server UI or via the gRPC interface to LoRa Server. In the case where gateway

and loraserver sit on the same host, set it to false.

6. network_server.gateway.stats.aggregation_intervals - defines collection time periods for

statistics gathering on gateways.

7. network_server.gateway.api.jwt_secret - a secret value used to generate the gateway

tokens. This can contain any value, for example the output of the following command

openssl rand -base64 32.

################################################################################################
start_loraserver:
sudo systemctl start loraserver
################################################################################################

Logging for loraserver is accessible via (add -f to follow):

sudo journalctl -u loraserver

################################################################################################

install_lora_app_server:
sudo apt-get install lora-app-server
################################################################################################

Edit /etc/lora-app-server/lora-app-server.toml

1. postgresql.dsn - The URL to the postgres server. Add username:password@ to the URL. e.g.,

postgres://loraserver_as:dbpassword@localhost/loraappserver?sslmode=disable. Be careful

with this setting. It is easy to get wrong, and can produce a number of different error

messages.

2. postgresql.automigrate - Leave this set to true, as it only takes a moment to run at server

startup, and ensures that database changes will always be applied with each upgrade.

3. application_server.integration.mqtt.username and

application_server.integration.mqtt.password - since the MQTT server is publicly accessible

(so LoRa Gateway Bridge instances can send data), it is best to have a username and

password for the server here. These credentials were the ones set up in the Mosquitto

authentication step.

4. application_server.api.bind - The port that serves up the api server. This should be

localhost:8001 as LoRa Server is on the same system.

5. application_server.external_api.bind - The port that serves up the public api server used

by the web UI. This is usually 0.0.0.0:8080 to enable access from all network interfaces,

but can be limited to a specific interface if desired.

6. application_server.external_api.tls_cert and application_server.external_api.tls_key -

These settings point to the certificate and key files and support SSL on the web ui REST

interface and the public gRPC interface. Since users log into the system via these

interfaces from remote systems, these settings are very important. Note that default files

are shipped with the software package, but they should be replaced for security.

7. application_server.external_api.jwt_serect - a secret value used to generate the JWT

returned as part of the login process, and is used again to verify the validity of the

token. This can be a classic password, or it could be a generated value such as one

generated by the command openssl rand -base64 32.

8. general.password_hash_iterations - The number of iterations to use to generate a password

hash. The goal is to have enough iterations that generation takes a second (and so

verification takes a second) making brute force login attacks painful to the attacker. The

default is a good place to start, but finding a good value for the server will take some

trial and error.

################################################################################################
start_lora_app_server:
sudo systemctl start lora-app-server
################################################################################################

Logging for LoRa App Server is accessible via (add -f to follow):

sudo journalctl -u lora-app-server

################################################################################################

################################################################################################

Setting up an initial application

In order to receive data from a device / node, that device must be associated with an

application. This can be done via the REST interface via some external application, or via

the UI that comes with LoRa App Server.

To access the LoRa App Server web-interface, enter the IP address of your server and the port

as defined in application_server.external_api.bind in your browser specifying the https

protocol in your browser’s address bar, example: https://localhost:8080.

This will forward to a login screen. A default administrator account is available at

installation time with the username of admin and a password of admin (it would be wise to

reset the password upon first login).

In order to connect you LoRa App Server instance with the LoRa Server instance, click Network

servers and then Add network-server. As LoRa Server is installed on the same host as LoRa App

Server, use localhost:8000 as network-server name.

After adding the network-server, click on LoRa Server to go back to the home screen. Then

open the Service profiles tab and click Create service-profile to create a service-profile

for the LoRa Server organization. This will also associate the organization with the

network-server instance.

After creating the service-profile, go to the Device profiles tab and click Create

device-profile. Here you can define the device properties and capabilities (e.g. OTAA vs ABP).

After connecting LoRa App Server with the LoRa Server network-server, creating a service- and

device-profile it is time to create your first application and add a device!

Go to the Applications tab and click the CREATE APPLICATION button, and add an application

for your device(s). This only requires an application name and description. Once the

application is created, you can click on the title to get a list of the devices associated

with the application (none at system installation). Click on the CREATE DEVICE button to

create the node (device). The basic fields that are required are the Device name,

Description, Device EUI and the Device-profile. After creating the device, you will be

redirected to a page to enter the AppKey in case of an OTAA device or to activate the device

in case of an ABP device.

Once the device and it application are created, the LoRa Server and LoRa App Server will be

able to handle messaging from the device.

################################################################################################

################################################################################################

Conclusion

At this point you should be able to follow the logs and see no errors. Also, you can user the

loraroot account on Mosquitto to watch the message flow:

mosquitto_sub -v -t “#” -u loraroot -P {password} -h localhost -p 1883

Where:

-v - verbose output - includes the topic of the message

-t “#” - any message. “#” is a multi-level wildcard. Other possibilities include:

“gateway/#” - any gateway messages

“application/#” - any application messages

-u - The user to log into mosquitto with

-P - The password for the user

-h - The host to log in to

-p - The mosquitto port

################################################################################################

1 Like

I thank you all for your patience and time. You really helped.

Related to my previous question, I found out that the lora-app-server is subscribed to the topic = application/AppId/deviceId/tx . but trying from the command line to access the logs or see what is going , using the command -->
mosquitto_sub -v -t “applicaton/#” -h localhost -p 1883
My question is , why can’t I see any output with the above commands, while the command ( mosquitto_sub-v-tc “#” -h localhost -p 1883 ) works and provides the the gateway stats

                                                                       -logs -


Jun 01 16:41:36 raspberrypi lora-app-server[735]: time=“2018-06-01T16:41:36+02:00” level=info msg=“handler/mqtt: publishing message” qos=0 topic=application/1/device/b827ebffffef85ff/join

If you use lora username and password file feature, you need to provide username and password:
mosquitto_sub -v -t “#” -u loraroot -P {password} -h localhost -p 1883

I didn’t create the username and password ( I did the configuration and installation as described in the quick install and every works well ) . Using the username and password file is an option to limit access to the broker, I think.
Q1- Shouldn’t it work with that command?
I am trying to create an application on top of the application server that will interact with the app-server sending commands to the node and also reading or receiving the node state. My node is periodically sending a state of an object placed in a remote area, my plan is tot receive this data an print it in my application , also it should be possible to change the state of the object from the application , by sending command to the node over the network.
Q2- what is it best to write an app that implements the application server api (gPRS)?

The subscription to the application finally works. Thanks guys…
:sweat_smile::sweat_smile::sweat_smile::sweat_smile::sweat_smile::sweat_smile::sweat_smile::smile:

hello, i’m traying to install the lora bridge on a rasberry pi 3
I’ve tried both commands for adding the key

apt-key adv --keyserver keyserver.ubuntu.com:80 --recv-keys 1CE2AFD36DBCCA00
Executing: /tmp/apt-key-gpghome.a9tKTvxN6w/gpg.1.sh --keyserver keyserver.ubuntu.com:80 --recv-keys 1CE2AFD36DBCCA00
gpg: keyserver receive failed: No keyserver available

and

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 1CE2AFD36DBCCA00
gpg: keyserver receive failed: No keyserver available

i get the same error.
to be mentioned that I have installed the dirmngr previously

other information:

root@raspberrypi:~# cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian

root@raspberrypi:~# lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.4 (stretch)
Release:        9.4
Codename:       stretch

please help
thanks