xsens / xsens_dot_server

34 stars 24 forks source link

Error running inside Docker: "uv_poll_start: Assertion '...' failed" #39

Closed RobertoRoos closed 2 years ago

RobertoRoos commented 2 years ago

I was trying to run the DOT server from inside Docker to experiment with it, but I can't get it to run.
I made the following Dockerfile, based on the instructions for Raspberry Pi:

FROM node:16

# Prepare packages
RUN apt-get update -q && apt-get install -y bluetooth bluez libbluetooth-dev libudev-dev \
    build-essential libssl-dev

# Prepare NodeJS
RUN npm install -g n && \
    n 8.11.1

# Get code
RUN cd ~ && git clone https://github.com/xsens/xsens_dot_server.git

WORKDIR /root/xsens_dot_server

# Run application
RUN npm install

EXPOSE 8080

CMD ["node", "xsensDotServer"]

But upon running the container I get the output with the error:

Web GUI Handler instantiated BLE Handler started. Webserver listening on port 8080, IP address: 172.17.0.2 node: ../deps/uv/src/unix/poll.c:120: uv_poll_start: Assertion `!(((handle)->flags & (UV_CLOSING | UV_CLOSED)) != 0)' failed.

I have no experience with NodeJS or NPM, so I am at a loss here.

RobertoRoos commented 2 years ago

Trying to get some more info.

I installed: npm install segfault-handler and added

const SegfaultHandler = require('segfault-handler');
SegfaultHandler.registerHandler('crash.log');

before the sensorServer() creation.

The output is now:

root@fb469ef5dc40:~/xsens_dot_server# node xsensDotServer.js Web GUI Handler instantiated BLE Handler started. Webserver listening on port 8080, IP address: 172.17.0.2 PID 893 received SIGSEGV for address: 0x0 /root/xsens_dot_server/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x31be)[0x7fe6e6e611be] /lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7fe6e9040730] node[0x140d669] node(uv_poll_start+0x3f)[0x141490f] /root/xsens_dot_server/node_modules/bluetooth-hci-socket/build/Release/binding.node(_ZN18BluetoothHciSocket5StartERKN3Nan20FunctionCallbackInfoIN2v85ValueEEE+0x62)[0x7fe6e6e589c2] /root/xsens_dot_server/node_modules/bluetooth-hci-socket/build/Release/binding.node(+0x3736)[0x7fe6e6e57736] node(_ZN2v88internal25FunctionCallbackArguments4CallEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEE+0x193)[0xb03853] node[0xb7a9ac] node(_ZN2v88internal21Builtin_HandleApiCallEiPPNS0_6ObjectEPNS0_7IsolateE+0xaf)[0xb7b5ff] [0x39d6048842fd] Segmentation fault (core dumped)

I have also tried npm rebuild from inside the running container and npm update --save, both make no difference.

RobertoRoos commented 2 years ago

I think I fixed it. The problem is the Bluetooth device was not available inside Docker. This is solved by running the container with (according to https://stackoverflow.com/questions/28868393/accessing-bluetooth-dongle-from-inside-docker):

docker run ... --net host --privileged ... 

Note that the host should not have a Bluetooth service running to prevent conflicts (sudo systemctl stop bluetooth).

I hope to have actual sensors with me next week to test it fully.

RobertoRoos commented 2 years ago

Yeah, that fixed it. Issue wasn't an Xsens issue to begin with so I'll close it.

Related PR opened at #42