Problems with Raspberry Pi image generator

Hi there,
I’ve generated a new image using https://github.com/brocaar/loraserver-pi-gen, there were few problems with it but I’ve managed to solve them using this forum :smile: .
Right now I can’t see the live events and frames, which is probably caused by:

INFO[1296] finished streaming call with code Unauthenticated error=“rpc error: code = Unauthenticated desc = authentication failed: get token from context error: no authorization-data in metadata” grpc.code=Unauthenticated grpc.method=StreamEventLogs grpc.service=api.Device grpc.start_time=“2018-07-07T16:56:17Z” grpc.time_ms=0.315 peer.address="[::1]:50816" span.kind=server system=grpc

So based on https://www.loraserver.io/lora-app-server/integrate/auth/ I’ve tocken with this claim:

{
“aud”: “lora-app-server”,
“exp”: 1600000000,
“iss”: “lora-app-server”,
“nbf”: 1530975101,
“sub”: “user”,
“username”: “admin”
}

and signed it with jwt_secret=“Y301pq2kbuKbZHHlrGCsIoiMf7UJAnlEerv8OHYD93Q=” from loraserver-pi-gen/stage3/04-loraserver/files/lora-app-server.toml

token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsb3JhLWFwcC1zZXJ2ZXIiLCJleHAiOjE2MDAwMDAwMDAsImlzcyI6ImxvcmEtYXBwLXNlcnZlciIsIm5iZiI6MTUzMDk3NTEwMSwic3ViIjoidXNlciIsInVzZXJuYW1lIjoiYWRtaW4ifQ.NXRvofQLfHU4VJw6OfNEiGYdTGooZsc1qQEJfJy9_XQ

It works with GET /api/devices/{devEUI}, but GET /api/devices/{devEUI}/events returns 504…

So my question is what’s next?
I’m guessing that I have to paste it to loraserver.toml, but in which section and under what field/variable name?

My second problem is empty fields/variables in a file generated by “loraserver configfile > test.toml”

PS Sorry for my bad English :blush:

Good one! I think in the Raspberry Pi image generator, the websocket proxy might be missing in the NGINX configuration. See also:

https://forum.loraserver.io/t/rpc-error-code-unauthenticated-and-live-frame-logs-live-event-disconnected/1093/9

If you would like to fix this and make a pull-request, that would be great :slight_smile:

That was it, thanks :slight_smile:

Sorry in advance for bad english :expressionless:
So, a small tutorial for dummies like me

  1. First of all, make sure that you use Ubuntu xenial (16.04) or newer
    (as stated in GitHub - RPi-Distro/pi-gen: Tool used to create the official Raspberry Pi OS images)
    I used Ubuntu 18.04 as VMware VM with 4GB RAM

  2. Install Docker

    sudo apt install docker.io
  3. Install dependencies image generator:

    sudo apt install quilt parted qemu-user-static debootstrap zerofree pxz zip dosfstools bsdtar libcap2-bin grep rsync

    There were also mentioned realpath as a required dependency in pi-gen but it’s depreciated module and the functionality of it was added into coreutils

  4. Clone repo using:

    git clone https://github.com/brocaar/loraserver-pi-gen.git

    Do not download it another way because at the last stage you’ll get an error about missing git files.

  5. Check if gpio reset pin number is correctly configured in the file:

    loraserver-pi-gen/stage3/02-packet-forwarder/files/start.sh

    The default value is: IOT_SK_SX1301_RESET_PIN=7 I had to change it to 25

  6. Change the default configuration on Nginx located in loraserver-pi-gen/stage3/04- loraserver/files/default from

       server {
           listen 80 default_server;
           listen [::]:80 default_server;
           server_name _;
           location / {
                   proxy_pass https://localhost:8080;
           }
        }

to:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name localhost;

        ssl_certificate /etc/lora-app-server/certs/http.pem;
        ssl_certificate_key /etc/lora-app-server/certs/http-key.pem;

        location ~ ^/api/(gateways|devices)/(\w+)/(frames|events)$ {
                proxy_pass https://localhost:8080/api/$1/$2/$3;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_read_timeout 86400s;
                proxy_send_timeout 86400s;
        }

        location / {
                proxy_pass https://localhost:8080/;
        }
}
  1. Start image generation by:

    sudo ./bubuild-docker.sh
  2. When the process finishes correctly there will be created a new directory with your image :slight_smile:

    loraserver-pi-gen/deploy

Huge thanks to @brocaar for creating awsome applications and his countinous help :smiley:
(maybe you could add this to repo wiki, if this is correct :slight_smile:)

1 Like

Thanks for the feedback! I’ve just updated the repo (locally). Will do a test build and then push my changes :slight_smile: