abandonware / noble

A Node.js BLE (Bluetooth Low Energy) central module : Community maintained
https://libraries.io/npm/@abandonware%2Fnoble
MIT License
544 stars 160 forks source link

(1967) uncaught exception: Cannot set property 'mtu' of undefined #91

Open r0b1zZle opened 4 years ago

r0b1zZle commented 4 years ago

Description
BLE Adapter is connecting well and consequently getting data from my flower sensors. Unfortunately every like 20 seconds the adapter is restarting due to an error.

Expected behavior
No errors.

Screenshots & Logfiles
` host.raspberrypi4-iob
2020-05-28 00:26:12.683 info Restart adapter system.adapter.ble.0 because enabled
host.raspberrypi4-iob 2020-05-28 00:26:12.683 info instance system.adapter.ble.0 terminated with code 0 (NO_ERROR)
host.raspberrypi4-iob 2020-05-28 00:26:12.683 error Caught by controller[6]: noble: unknown peripheral 001a220754a6 handle notify!
host.raspberrypi4-iob 2020-05-28 00:26:12.683 error Caught by controller[5]: at Hci.emit (events.js:315:20)
host.raspberrypi4-iob 2020-05-28 00:26:12.683 error Caught by controller[5]: at NobleBindings.onAclDataPkt (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:288:15)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at AclStream.push (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/acl-stream.js:33:10)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at AclStream.emit (events.js:327:22)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at Gatt.onAclStreamData (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:133:26)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at Object.callback (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:329:10)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at Gatt.emit (events.js:315:20)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at NobleBindings.onMtu (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:277:8)
host.raspberrypi4-iob 2020-05-28 00:26:12.682 error Caught by controller[5]: at NobleBindings.emit (events.js:315:20)
host.raspberrypi4-iob 2020-05-28 00:26:12.681 error Caught by controller[5]: at Noble.onMtu (/opt/iobroker/node_modules/@abandonware/noble/lib/noble.js:564:18)
host.raspberrypi4-iob 2020-05-28 00:26:12.681 error Caught by controller[5]: TypeError: Cannot set property 'mtu' of undefined
host.raspberrypi4-iob 2020-05-28 00:26:12.681 error Caught by controller[4]: at Hci.emit (events.js:315:20)
host.raspberrypi4-iob 2020-05-28 00:26:12.681 error Caught by controller[4]: at NobleBindings.onAclDataPkt (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:288:15)
host.raspberrypi4-iob 2020-05-28 00:26:12.681 error Caught by controller[4]: at AclStream.push (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/acl-stream.js:33:10)
host.raspberrypi4-iob 2020-05-28 00:26:12.681 error Caught by controller[4]: at AclStream.emit (events.js:327:22)
host.raspberrypi4-iob 2020-05-28 00:26:12.680 error Caught by controller[4]: at Gatt.onAclStreamData (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:133:26)
host.raspberrypi4-iob 2020-05-28 00:26:12.680 error Caught by controller[4]: at Object.callback (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:329:10)
host.raspberrypi4-iob 2020-05-28 00:26:12.680 error Caught by controller[4]: at Gatt.emit (events.js:315:20)
host.raspberrypi4-iob 2020-05-28 00:26:12.680 error Caught by controller[4]: at NobleBindings.onMtu (/opt/iobroker/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:277:8)
host.raspberrypi4-iob 2020-05-28 00:26:12.680 error Caught by controller[4]: at NobleBindings.emit (events.js:315:20)
host.raspberrypi4-iob 2020-05-28 00:26:12.680 error Caught by controller[4]: at Noble.onMtu (/opt/iobroker/node_modules/@abandonware/noble/lib/noble.js:564:18)
host.raspberrypi4-iob 2020-05-28 00:26:12.679 error Caught by controller[4]: TypeError: Cannot set property 'mtu' of undefined
host.raspberrypi4-iob 2020-05-28 00:26:12.679 error Caught by controller[3]: noble: unknown peripheral 001a220754a6 connected!
host.raspberrypi4-iob 2020-05-28 00:26:12.679 error Caught by controller[2]: noble: unknown peripheral 001a220754a6 disconnected!
host.raspberrypi4-iob 2020-05-28 00:26:12.678 error Caught by controller[1]: noble: unknown peripheral 001a220754a6 connected!
ble.0 2020-05-28 00:26:12.162 info (1967) Terminated (NO_ERROR): Without reason
ble.0 2020-05-28 00:26:12.161 info (1967) terminating
ble.0 2020-05-28 00:26:12.150 error (1967) TypeError: Cannot set property 'mtu' of undefined at Noble.onMtu (/opt/iobroker/node_modules/@abandonware/noble/lib/noble.js:564:18) at NobleBindings.emit (events.js:315:20) at Nobl
ble.0 2020-05-28 00:26:12.149 error (1967) uncaught exception: Cannot set property 'mtu' of undefined
ble.0 2020-05-28 00:26:12.143 info (1967) stopping scan
ble.0 2020-05-28 00:26:12.141 error (1967) TypeError: Cannot set property 'mtu' of undefined at Noble.onMtu (/opt/iobroker/node_modules/@abandonware/noble/lib/noble.js:564:18) at NobleBindings.emit (events.js:315:20) at Nobl
ble.0 2020-05-28 00:26:12.140 error (1967) uncaught exception: Cannot set property 'mtu' of undefined

`

Versions:

pi@raspberrypi4-iob:~ $ nodejs -v && node -v && npm -v
  | v12.17.0
  | v12.17.0
  | 6.14.4
pi@raspberrypi4-iob:~ $ which nodejs && which node && which npm
  | /usr/bin/nodejs
  | /usr/bin/node
  | /usr/bin/npm
rzr commented 4 years ago

Can you please also compare with earlier versions ?

r0b1zZle commented 4 years ago

Can you please also compare with earlier versions ?

What do you mean? Which earlier versions?

AlCalzone commented 4 years ago

@rzr @r0b1zZle The BLE adapter is using noble 1.9.2-8. Any specific versions we should compare with?

r0b1zZle commented 4 years ago

Updated to js-controller: 3.1.4, still the same issue.

Fabryz commented 4 years ago

My app just crashed with:

"Cannot set property 'mtu' of undefined"
/node_modules/@abandonware/noble/lib/noble.js:564
peripheral.mtu = mtu;

Ubuntu Server 18.04, NodeJS 12.18.2, Noble 1.9.2-8. Before the error I had a warning event, but the message was emtpy.

2020-07-22T13:19:22.348Z [info] [START] Scanning for devices with service xyz...
2020-07-22T13:19:22.348Z [info]
2020-07-22T13:19:28.911Z [info]
2020-07-22T13:19:28.912Z [warn] Warning message:
2020-07-22T13:19:28.913Z [info]
2020-07-22T13:19:28.914Z [info]
2020-07-22T13:19:28.914Z [info] [STOP] Stopped scanning.
2020-07-22T13:19:28.915Z [info]
/home/node_modules/@abandonware/noble/lib/noble.js:564
peripheral.mtu = mtu;
                ^

[  TypeError: Cannot set property 'mtu' of undefined

- noble.js:564 Noble.onMtu
    [contact-tracing]/[@abandonware]/noble/lib/noble.js:564:18

- events.js:315 NobleBindings.emit
    events.js:315:20

- bindings.js:277 NobleBindings.onMtu
    [contact-tracing]/[@abandonware]/noble/lib/hci-socket/bindings.js:277:8

- events.js:315 Gatt.emit
    events.js:315:20

- gatt.js:329 Object.callback
    [contact-tracing]/[@abandonware]/noble/lib/hci-socket/gatt.js:329:10

- gatt.js:133 Gatt.onAclStreamData
    [contact-tracing]/[@abandonware]/noble/lib/hci-socket/gatt.js:133:26

- events.js:327 AclStream.emit
    events.js:327:22

- acl-stream.js:33 AclStream.push
    [contact-tracing]/[@abandonware]/noble/lib/hci-socket/acl-stream.js:33:10

- bindings.js:288 NobleBindings.onAclDataPkt
    [contact-tracing]/[@abandonware]/noble/lib/hci-socket/bindings.js:288:15

- events.js:315 Hci.emit
    events.js:315:20

]

This never happened in two months of developing with the library, so it's not easy to reproduce. I just hope it won't crash during critical times

Patronics commented 4 years ago

I also just got this error in noble (on node 14.10.1, but not on a similar system running node 12.19.0), did you ever find a solution?

Fabryz commented 4 years ago

I also just got this error in noble (on node 14.10.1, but not on a similar system running node 12.19.0), did you ever find a solution?

Nope, it didn't happen again, but also I had to work on another different project shortly after so I couldn't continue debugging....

mylylyl commented 3 years ago

I had the same issue (#164) and I add a PR for it (#165) but in the meantime you can just apply my changes if you still have this issue

Jacksonbm1 commented 3 years ago

Sorry, can you clarify what changes you're referring to @fisherwise?