Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using noble within a docker container #43

Open
jackbridger opened this issue Feb 18, 2020 · 12 comments
Open

Using noble within a docker container #43

jackbridger opened this issue Feb 18, 2020 · 12 comments

Comments

@jackbridger
Copy link

jackbridger commented Feb 18, 2020

I am trying to use noble in a node (v13.8.0) app running in a local docker container.

When I run my application I receive the below error. It seems like there is an issue with hci-socket.

`/app/node_modules/@abandonware/noble/lib/hci-socket/hci.js:75
this._socket = new BluetoothHciSocket();
^

Error: EAFNOSUPPORT, Address family not supported by protocol
at new Hci (/app/node_modules/@abandonware/noble/lib/hci-socket/hci.js:75:18)
at new NobleBindings (/app/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:28:15)
at Object. (/app/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:511:18)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
at module.exports (/app/node_modules/@abandonware/noble/lib/resolve-bindings.js:13:12) {
errno: 97,
code: 'EAFNOSUPPORT',
syscall: 'socket'
}
`

I found this on noble noble#805

Does anyone have a workaround?

Thanks!

@rzr
Copy link

rzr commented Feb 18, 2020

I suspect problem in docker run params ?
Maybe we can add a docker-compose file

@jackbridger
Copy link
Author

jackbridger commented Feb 19, 2020

Thanks, these are the docker commands I'm using:

docker build -t mqtt-server .
docker run -it -p 9002:3002 -v $(pwd):/app mqtt-server /bin/bash

My Dockerfile:

`FROM node:latest

WORKDIR specifies the directory our
WORKDIR /app
RUN npm install -g nodemon
COPY package.json /app/package.json
RUN npm install && npm ls
RUN mv /app/node_modules /node_modules
COPY . /app
`
Package.json:

`
{
"name": "TIG-docker",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@abandonware/noble": "^1.9.2-5",
"mqtt": "^3.0.0"
}
}

`

@rzr
Copy link

rzr commented Feb 19, 2020

Is the problem in mqtt or noble module ?

Maybe try to play along different network mode, I used:

https://github.com/rzr/webthing-iotjs/blob/master/docker-compose.yml#L21

@jackbridger
Copy link
Author

jackbridger commented Feb 19, 2020

Thanks @rzr , Having done some more research, I think it's the bluetooth module in noble because I'm running docker locally on a mac but haven't found a solution so far?

https://forums.docker.com/t/cannot-access-macbook-built-in-bluetooth-in-docker-debian-container/32819 Maybe it's not to do with noble

@rzr
Copy link

rzr commented Feb 19, 2020

Sorry I am a linux user but I can give a try, may you open a PR with docker-compose file running a sample self test and I'll try it and will share you logs

@C4mp3r-Grey
Copy link

Hello! As AcCalzone mentioned, I am running into the same phenomenon here AlCalzone/ioBroker.ble#422 (comment)

I have closed it, as it does not seem to be an AlCalzone/BLE issue then.

Any update on this here?

@C4mp3r-Grey
Copy link

Maybe this issue can be solved as I solved mine:

Run the container with --net host rather than shared.

Although this thread is pretty old, it may help others to find the own mistake as I did after several days? buanet/ioBroker.docker#134 (comment)

@rzr
Copy link

rzr commented Sep 6, 2020

feel free to add a chapter in readme file about using with docker

@atrovato
Copy link

Hi, did you run noble within a Docker container?
Can you share your Dockerfile, I'm not sure of required dependencies and commands to run.

@hkayann
Copy link

hkayann commented Oct 21, 2021

I have developed my own npm package that depends on @abandonware/noble

I am having a similar issue. Here is the error:

[node-red-contrib-ble-sense/protocols] Error: EAFNOSUPPORT, Address family not supported by protocol

I am running Node-RED on RPi 4 that runs DietPi.

@SSharshunov
Copy link

Я разработал свой собственный пакет npm, который зависит от@abandonware/noble

У меня похожая проблема. Вот ошибка:

[node-red-contrib-ble-sense/protocols] Error: EAFNOSUPPORT, Address family not supported by protocol

Я запускаю Node-RED на RPi 4, на котором работает DietPi.

Use --net=host for docker cli, to resolve this problem (EAFNOSUPPORT)

@ianchanning
Copy link

This is indeed now written up in the README > Docker section: https://github.com/abandonware/noble/#docker

Thanks to @atrovato ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants