Code Monkey home page Code Monkey logo

Comments (15)

mrstegeman avatar mrstegeman commented on July 17, 2024 1

Added some notes to the README. Thanks for bringing up the issue, I had never encountered it!

from gateway-docker.

white-gecko avatar white-gecko commented on July 17, 2024 1

Cool, yes it works. Didn't know I had to add the "Web Thing" add-on I thought this is native.

from gateway-docker.

mrstegeman avatar mrstegeman commented on July 17, 2024 1

Great! I'm rebuilding the Docker images and will push to Docker Hub shortly.

from gateway-docker.

mrstegeman avatar mrstegeman commented on July 17, 2024

It seems like the gateway Docker image is unable to do mDNS resolution on your network. Are you running your container in host networking mode? I'm guessing we need to add avahi-daemon libnss-mdns to the Docker image, but that seems to be... complicated.

See: https://stackoverflow.com/questions/30646943/how-to-avahi-browse-from-a-docker-container

from gateway-docker.

matiasdelellis avatar matiasdelellis commented on July 17, 2024

Ohh.. It seems to be on that side.. Evidently, the gateway docker discovers it, but cannot access it..

Executing the command inside the container (I should have tried it before 😅 ) fail.

[matias@nube ~]$ sudo docker exec -it 41db43129204 curl -i -H "Accept: application/json" "http://ac-controller.local:80"
curl: (6) Could not resolve host: ac-controller.local

But if I use the ip it works.. 😃

[matias@nube ~]$ sudo docker exec -it 41db43129204 curl -i -H "Accept: application/json" "http://192.168.1.246:80"
HTTP/1.1 200 OK
Content-Length: 872
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: PUT, GET, OPTIONS
Connection: close
Accept-Ranges: none

[{"id":"ac","title":"Air Conditioning Controller","@context":"https://iot.mozilla.org/schemas","securityDefinitions":{"nosec_sc":{"scheme":"nosec"}},"@type":["OnOffSwitch"],"links":[{"rel":"properties","href":"/things/ac/properties"},{"rel":"events","href":"/things/ac/events"},{"rel":"alternate","href":"ws://192.168.1.246:80/things/ac"}],"properties":{"ambientHum":{"type":"number","readOnly":true,"unit":"%","@type":"AmbientHumProperty","links":[{"href":"/things/ac/properties/ambientHum"}]},"ambientTemp":{"type":"number","readOnly":true,"unit":"°C","@type":"AmbientTempProperty","links":[{"href":"/things/ac/properties/ambientTemp"}]},"setTemp":{"type":"number","unit":"°C","@type":"TempProperty","links":[{"href":"/things/ac/properties/setTemp"}]},"on":{"type":"boolean","@type":"OnOffProperty","links":[{"href":"/things/ac/properties/on"}]}},"href":"/things/ac"}

Thanks @mrstegeman ,
I guess you can close it, and open it in the docker repository.

from gateway-docker.

matiasdelellis avatar matiasdelellis commented on July 17, 2024

Sorry..

Are you running your container in host networking mode?

You mean this?

So, yes. In these test I am using:

sudo docker run -d --rm -v /usr/share/mozilla-iot:/home/node/.mozilla-iot --net=host --name mozilla-iot-gateway mozillaiot/gateway:latest

from gateway-docker.

mrstegeman avatar mrstegeman commented on July 17, 2024

I've been playing around, and here's what I've discovered:

  1. nss-mdns (the mDNS resolution library) only works with avahi-daemon running.
  2. avahi-daemon has a hard dependency on dbus.
  3. dbus doesn't really work inside a Docker container.
  4. You can share in the dbus socket from the host, or use the running avahi-daemon instance from the host, but that's pretty terrible for users.
  5. We could get around all of this by using IP addresses, rather than <hostname>.local, in thing-url-adapter. However, that falls apart if the host is then assigned a new IP address via DHCP.
  6. Sticking with IP addresses in the config is probably the best workaround for this issue.

from gateway-docker.

matiasdelellis avatar matiasdelellis commented on July 17, 2024

Hi,

Sticking with IP addresses in the config is probably the best workaround for this issue.

Well, I guess it's acceptable as an optional configuration.. Disabled by default, and documented in this repo to use when necessary.

However, that falls apart if the host is then assigned a new IP address via DHCP.

I insist on the optional for this reason, since it is a problem of this implementation, and most of the potential users will not implement the gateway using docker.

Thanks for investigating.

from gateway-docker.

white-gecko avatar white-gecko commented on July 17, 2024

I have the gateway running in docker on an olimex board running armbian (https://www.armbian.com/olimex-lime-2/). I additionally had to install libnss-mdns (which also depends on avahi-daemon). So far about my environment.
Can anybody explain, how to mount the avahi daemon into the docker environment? Where is the socket usually running, and where does the gateway docker expect it? Maybe this could also be added to the README as well.

from gateway-docker.

white-gecko avatar white-gecko commented on July 17, 2024

I found the socket under /var/run/avahi-daemon/socket on the host but just mounting it to the smae path /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket did not do the trick.

from gateway-docker.

mrstegeman avatar mrstegeman commented on July 17, 2024

I don't think the avahi socket is the problem, it's the lack of dbus.

from gateway-docker.

white-gecko avatar white-gecko commented on July 17, 2024

What about running a dbus inside the docker image: https://stackoverflow.com/a/45274624/414075

Or use it like this: https://github.com/mviereck/x11docker/wiki/How-to-connect-container-to-DBus-from-host

from gateway-docker.

mrstegeman avatar mrstegeman commented on July 17, 2024

The second one is probably preferable, if you can get it to work. I've tried running dbus inside containers in the past and have had very bad luck. Please let me know if you get a solution working, though!

from gateway-docker.

white-gecko avatar white-gecko commented on July 17, 2024

With my pull request the libnss-mdns and avahi-daemon is included. The avahi-daemon can be started with enable-dbus=no in the configuration.
When I enter the container with docker exec -it … /bin/bash I can ping my .local devices which was not possible before.
But somehow the WebThings gateway does only do "Scanning for new devices... " but does not find the single-thing (https://github.com/mozilla-iot/webthing-python/blob/master/example/single-thing.py) that is running on the computer that can be pinged using its hostename.local from within the container.

from gateway-docker.

mrstegeman avatar mrstegeman commented on July 17, 2024

This is fantastic! I'm able to find and add devices just fine now.

Questions:

  1. Do you have the "Web Thing" add-on installed?
  2. Are you able to add that host by using the "Add by URL" feature?

from gateway-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.