WebThingsIO / registration_server

The registration server for WebThings Gateway.
Mozilla Public License 2.0
79 stars 33 forks source link

Cannot /subscribe to Registration Server: dbtype=sqlite #75

Closed napat1412 closed 5 years ago

napat1412 commented 5 years ago

What happened: I build docker: Registration Server: dbtype=sqlite (wot.service.local, os: centos 7) and run pagekite client for service: https (c.wot.service.local, os: centos 7). I can access service: https through https://c.wot.service.local but i cannot /subscribe c.wot.service.local to Registration Server.

What you expected to happen: I can use /subscribe & /reclaim for new device registration

How to reproduce it (as minimally and precisely as possible):

systemctl start nginx (run at port 80 & set confugration-file )

docker run --name wot -d -v /opt/docker-run/registration_server/data:/home/user/data -v /opt/docker-run/registration_server/config:/home/user/config -p 81:81 -p 444:4444 -p 443:4443 -p 53:53 -p 53:53/udp local/registration_server:0.1

netstat -tna | grep LISTEN

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp6       0      0 :::81                   :::*                    LISTEN
tcp6       0      0 :::53                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN
tcp6       0      0 :::443                  :::*                    LISTEN
tcp6       0      0 :::444                  :::*                    LISTEN

I run nginx:https and pagekite client.

$ docker restart wot $ docker logs -f wot

+ ROOT_DIR=/home/user/config
+ source /home/user/config/env
++ DOMAIN=wot.service.local
++ export RUST_LOG=debug
++ RUST_LOG=debug
+ pdns_server --config-dir=/home/user/config
Aug 25 02:11:16 Reading random entropy from '/dev/urandom'
+ '[' -n '' ']'
+ RUST_LOG=registration_server=debug,maxminddb=info
+ ./target/release/main --config-file=/home/user/config/config.toml
+ pagekite.py --isfrontend --ports=4443 --protos=https --authdomain=wot.service.local
DEBUG:<unknown>: new(): Opening database at postgres://USER:PASS@IP:5432/DB
DEBUG:<unknown>: start_socket_endpoint(): Starting the pdns socket endpoint at /tmp/powerdns_tunnel.sock
started=/usr/local/bin/pagekite.py; ll=0; ts=5b80bac5; argv=--isfrontend --ports=4443 --protos=https --authdomain=wot.service.local; platform=linux2; version=0.5.9.3; t=2018-08-25T02:11:17; ca_certs=/etc/ssl/certs/ca-certificates.crt
info=Collecting entropy for a secure secret.; ll=1; ts=5b80bac5; t=2018-08-25T02:11:17
debug=Seeded signatures using /dev/urandom, hooray!; ll=2; ts=5b80bac5; t=2018-08-25T02:11:17
debug=UiComm: Created; ll=3; ts=5b80bac5; t=2018-08-25T02:11:17
id=s0; ll=4; listen=:4443; ts=5b80bac5; t=2018-08-25T02:11:17
ts=5b80bac5; t=2018-08-25T02:11:17; ll=5; debug=TunnelManager: loop #1, interval=5
ts=5b80bac5; t=2018-08-25T02:11:17; ll=6; debug=Not sure which servers to contact, making no changes.ts=5b80bac5; t=2018-08-25T02:11:17; ll=7; debug=Entering main epoll loop

ts=5b80bac7; t=2018-08-25T02:11:19; ll=8; accept=~97.15:38836; id=s0
ts=5b80bac7; t=2018-08-25T02:11:19; ll=9; debug=No back-end; on_port=4443; proto=http; domain=ping.pagekite; is=FE; id=s1/~97.15:38836
ts=5b80bac7; t=2018-08-25T02:11:19; ll=a; wrote=409; wbps=0; read=0; eof=1; id=s1/~97.15:38836
ts=5b80bac7; t=2018-08-25T02:11:19; ll=b; accept=~97.15:38838; id=s0
ts=5b80bac7; t=2018-08-25T02:11:19; ll=c; debug=No tunnels configured, idling...; id=s2/~97.15:38838
ts=5b80bac8; t=2018-08-25T02:11:20; ll=d; BE=Live; proto=https; domain=c.wot.service.local; add_kites=True; version=0.5.9.3; id=s2/~97.15:38838
ts=5b80baca; t=2018-08-25T02:11:22; ll=e; debug=Not sure which servers to contact, making no changes.
ts=5b80bacf; t=2018-08-25T02:11:27; ll=f; debug=Not sure which servers to contact, making no changes.
ts=5b80bad4; t=2018-08-25T02:11:32; ll=10; debug=Not sure which servers to contact, making no changes.

Now i can access https://c.wot.service.local $ curl -k https://c.wot.service.local

$ docker logs -f wot

ts=5b80bb33; t=2018-08-25T02:13:07; ll=27; debug=Not sure which servers to contact, making no changes.
ts=5b80bb38; t=2018-08-25T02:13:12; ll=28; debug=Not sure which servers to contact, making no changes.
ts=5b80bb3b; t=2018-08-25T02:13:15; ll=29; accept=~97.15:38846; id=s0
ts=5b80bb3c; t=2018-08-25T02:13:16; ll=2a; domain=c.wot.service.local; on_port=4443; proto=https; is=FE; id=s5/~97.15:38846
ts=5b80bb3c; t=2018-08-25T02:13:16; ll=2b; wrote=5406; wbps=4218; read=269; eof=1; id=s5/~97.15:38846
ts=5b80bb3d; t=2018-08-25T02:13:17; ll=2c; debug=Not sure which servers to contact, making no changes.
ts=5b80bb42; t=2018-08-25T02:13:22; ll=2d; debug=Not sure which servers to contact, making no changes.

$ docker logs -f wot

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: IoError("entity not found")', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
ts=5b80bbc4; t=2018-08-25T02:15:32; ll=4a; debug=Not sure which servers to contact, making no changes.
ts=5b80bbc9; t=2018-08-25T02:15:37; ll=4b; debug=Not sure which servers to contact, making no changes.
* About to connect() to wot.service.local port 80 (#0)
*   Trying x.x.x.x...
* Connected to wot.service.local (x.x.x.x) port 80 (#0)
> GET /reclaim HTTP/1.1
> User-Agent: curl/7.29.0
> Host: wot.service.local
> Accept: */*
> Content-Type: application/json
> Content-Length: 12
>
* upload completely sent off: 12 out of 12 bytes
< HTTP/1.1 400 Bad Request
< Server: nginx/1.12.2
< Date: Sat, 25 Aug 2018 05:01:54 GMT
< Content-Type: application/json
< Content-Length: 23
< Connection: keep-alive
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: accept, authorization, content-type
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE
<
* Connection #0 to host wot.service.local left intact
{"error": "NoSuchName"}

$ docker logs -f wot

ts=5b80bc1e; t=2018-08-25T02:17:02; ll=5e; debug=Not sure which servers to contact, making no changes.
ts=5b80bc23; t=2018-08-25T02:17:07; ll=5f; debug=Not sure which servers to contact, making no changes.
INFO:<unknown>: GET /reclaim {"name": "c"}
ts=5b80bc28; t=2018-08-25T02:17:12; ll=60; debug=Not sure which servers to contact, making no changes.
ts=5b80bc2d; t=2018-08-25T02:17:17; ll=61; debug=Not sure which servers to contact, making no changes.

What is the problem? about registration server configuration or subscribe method.

*Note: edit 1: add curl command for json data

napat1412 commented 5 years ago

The problem is the incorrect configuration. In file CONFIG_DIR/config.toml, variable: database in [pdns.geoip] is "/home/user/geoip/GeoLite2-Country.mmdb" but it's wrong path. User must change the variable: database to correct path.

Old configuration

  [pdns.geoip]
  default = "5.6.7.8"
  database = "/home/user/geoip/GeoLite2-Country.mmdb"

New configuration

  [pdns.geoip]
  default = "5.6.7.8"
  database = "/home/user/test-data/GeoLite2-Country_20180206/GeoLite2-Country.mmdb"