WebThingsIO / thing-url-adapter

Proxy adapter for Web Thing API endpoints
Mozilla Public License 2.0
22 stars 18 forks source link

Missing README #5

Closed Timmeey closed 6 years ago

Timmeey commented 6 years ago

I wanted to build a Java-web-thing (https://github.com/mozilla-iot/webthing-java).

My javascript skills are not the best, but upon reading your code i thought i would discover avahi/zeroconf/... services in the local network and give me some interface or so to add those to my things, if they present the wot api.

Using that demo application i'm able to announce the service in my local network. THe app is running on my laptop, while things gateway is running on a PI. Now i can discover the service, running on my laptop from the pi (ssh -> avahi-browse), so the web-thing service is working. But your adapter doesn't show me anything.

Reproduce:

  1. run the given example https://github.com/mozilla-iot/webthing-java on a different machine in the local network
  2. check if the service is properly announcing itself by checking if avahi-browse on the PI (that is running the gateway) shows the service.
  3. clone thing-url-adapter to the src/addon directory of the gateway
  4. restart gateway service
  5. add thing-url-adapter as an addon via the UI
  6. restart gateway service (just to make sure)
  7. try to add a "Thing" in the main view.
  8. No thing discovered

It is possible that i completely misunderstood what this plugin is intended for. SO i hope you could give a small readme on how to use it.

mrstegeman commented 6 years ago

In the near future, this will be installable via the gateway's UI, so the manual installation steps won't be necessary. I think what you probably missed is building the package. After cloning the add-on, you'll need to run the package.sh script inside to pull down the appropriate node.js dependencies.

Timmeey commented 6 years ago

Thank you. Yeah. that helped. At least now i get a reaction in the logs

Mar 23 14:31:54 gateway node[20534]: *** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
Mar 23 14:31:54 gateway node[20534]: *** WARNING *** Please fix your application to use the native API of Avahi!
Mar 23 14:31:54 gateway node[20534]: *** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>

But that is a different error.

Would still be great to have a very brief readme with steps for devs to get it running, so we can start hacking on our devices that are connected via lan/wifi

mrstegeman commented 6 years ago

That looks like just a warning to me. Is the adapter successfully finding your mDNS devices now?

Timmeey commented 6 years ago

Unfortunately it doesn't. But i'm also not sure how to debug it.

It never makes a call to the actual API (The breakpoint on accepting to socket connection in the java-web-thing never triggers when scanning, only when i open the site manually)

How can i get (more) logs out of your gateway plugin?

mrstegeman commented 6 years ago

Are you testing on the Raspberry Pi? I'm doing so right now and am having issues as well. The run-app.log file (or console, if starting manually) is the primary source of logging.

Timmeey commented 6 years ago

The things gateway is running on the pi, the java-web-thing api is running on my laptop.

does that help?

2018-03-23 15:09:23.370 thing-url: noble warning: adapter state unauthorized, please run as root or with sudo
2018-03-23 15:09:23.370 thing-url:                or see README for information on running without root/sudo:
2018-03-23 15:09:23.371 thing-url:                https://github.com/sandeepmistry/noble#running-on-linux
2018-03-23 15:09:23.433 thing-url: events.js:183
2018-03-23 15:09:23.433 thing-url:       throw er; // Unhandled 'error' event
2018-03-23 15:09:23.436 thing-url:       ^
2018-03-23 15:09:23.436 thing-url: 
2018-03-23 15:09:23.436 thing-url: Error: getaddrinfo -3008
2018-03-23 15:09:23.436 thing-url:     at errnoException (/home/pi/mozilla-iot/gateway/build/addons/thing-url-adapter/node_modules/mdns/lib/resolver_sequence_tasks.js:199:11)
2018-03-23 15:09:23.436 thing-url:     at getaddrinfo_complete (/home/pi/mozilla-iot/gateway/build/addons/thing-url-adapter/node_modules/mdns/lib/resolver_sequence_tasks.js:112:10)
2018-03-23 15:09:23.436 thing-url:     at GetAddrInfoReqWrap.oncomplete (/home/pi/mozilla-iot/gateway/build/addons/thing-url-adapter/node_modules/mdns/lib/resolver_sequence_tasks.js:120:9)
2018-03-23 15:09:23.442 Plugin: thing-url-adapter died, code = 1 restarting...

At least i don't feel completely stupid, if you also have issues....

mrstegeman commented 6 years ago

Yes, that's exactly what I got. I stopped the avahi-daemon systemd service and that error went away, but my devices are still not being found.

Timmeey commented 6 years ago

We should move this discussion to its won issue, so others with the same issue can find it more easy.

mrstegeman commented 6 years ago

@Timmeey #7 fixes the issue and adds a README.

Timmeey commented 6 years ago

Confirmed. Works for me now, finds the "lamp".

Thanks for the effort and the Readme