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

UnhandledPromiseRejectionWarning and other errors #34

Open
corgan2222 opened this issue May 19, 2021 · 6 comments
Open

UnhandledPromiseRejectionWarning and other errors #34

corgan2222 opened this issue May 19, 2021 · 6 comments

Comments

@corgan2222
Copy link

I tried now for months to get this running stable, but every few minutes it stopped working.
And i can't really reproduce the problem. Its such a strange behavior.

I restart bluetooth, the restart the keyble-mqtt service.
And some seconds later i get this error.

18:52:03 raspizero2 keyble-mqtt.sh[23658]: (node:23659) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'write' of undefined │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at Key_Ble.send_message_fragment (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:498:28) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at processTicksAndRejections (internal/process/task_queues.js:93:5) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_message_fragments (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:506:4) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_message (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:530:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.ensure_nonces_exchanged (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:575:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_message (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:513:4) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_command (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:405:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.lock (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:364:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async MqttClient. (/opt/nodejs/lib/node_modules/keyble-mqtt/keyble-mqtt.js:159:7) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: (Use node --trace-warnings ... to show where the warning was created) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: (node:23659) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: (node:23659) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js p│

grafik

Then i repeat this, restart BT and keyble i got a different error from noble


│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: /opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/@abandonware/noble/lib/hci-socket/hci.js:120 │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: this._socket.bindRaw(this._deviceId); │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: ^ │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: Error: EALREADY, Operation already in progress │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at Hci.init (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/@abandonware/noble/lib/hci-socket/hci.js:120:18) │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at Hci.pollIsDevUp (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/@abandonware/noble/lib/hci-socket/hci.js:135:14) │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at listOnTimeout (internal/timers.js:554:17) │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at processTimers (internal/timers.js:497:7) { │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: errno: 114, │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: code: 'EALREADY', │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: syscall: 'bind' │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: }

grafik

And now, if I repeat this one more time, restart bt and keyble, I get this smp error, but keyble does the job and turn the key.
At first i was worried about the snp error, but now its a hint that the communication is working.

grafik

This behavior is completely random.
ATM i have a cron job running, which restarts BT and keyble every 5min, but even with this, the chance that the look opens if needed are <50%.

Is there anything i can do to help?

@corgan2222
Copy link
Author

running on a pi zero

Linux raspizero2 5.10.17+

Drivers:
ii bluetooth 5.50-1.2deb10u1+rpt2 all Bluetooth support (metapackage)
ii bluez 5.50-1.2
deb10u1+rpt2 armhf Bluetooth tools and daemons
ii bluez-firmware 1.2-4+rpt8 all Firmware for Bluetooth devices
ii bluez-hcidump 5.50-1.2deb10u1+rpt2 armhf Analyses Bluetooth HCI packets
ii libbluetooth-dev:armhf 5.50-1.2
deb10u1+rpt2 armhf Development files for using the BlueZ Linux Bluetooth library
ii libbluetooth3:armhf 5.50-1.2~deb10u1+rpt2 armhf Library to use the BlueZ Linux Bluetooth stack
ii lxplug-bluetooth 0.21 armhf Bluetooth plugin for lxpanel
ii pi-bluetooth 0.1.16 all Raspberry Pi 3 bluetooth
ii pulseaudio-module-bluetooth 12.2-4+deb10u1+rpi3 armhf Bluetooth module for PulseAudio sound server

@jeeck-jan
Copy link

Had the same problems for a long time.
Found a solution by mirovdm/le_autoconnect_timeout.md in github
"This tool changes default HCI_LE_AUTOCONN_TIMEOUT for Bluetooth adapter on Linux"
And it works fine !

@oyooyo
Copy link
Owner

oyooyo commented Dec 14, 2022

Hello @jeeck-jan,
could you provide a link where I can find some more information on this?

@jeeck-jan
Copy link

jeeck-jan commented Dec 14, 2022 via email

@oyooyo
Copy link
Owner

oyooyo commented Dec 15, 2022

@jeeck-jan Thanks!

@jeeck-jan
Copy link

Some advice to make keyble software function fast and sure : for raspberry pi

1 enable bluetooth in /boot config.txt #dtoverlay=disable-bt
2 enable hciuart : sudo systemctl start hciuart
3 trust doorlock : sudo bluetoothctl trust xx:xx:xx:xx:xx (doorlock mac adresss), this is not so easy, do it in loop in python or
manually in bluetoothctl (several times till successful); you only have to do this one's : stays in raspi's memory : this speeds up
connection
4 adjust le connect timeout : see above (you can do this one's at every pi reboot )
5 do not change settings for --status_update_time : if to short your commands will be overruled by the status command, and
the doorlock will not move. (and you don't know what's happening)
6 I change the setting for timeout --timeout to 20, if you don't get a reaction after 10 seconds, you won't get any. This setting
is not realy necessary : I always have reaction in less than 10 seconds.
7 this is very important : before sending a command : stop bluetooth (sudo systemctl stop bluetooth), and then start bluetooth
(sudo systemctl start bluetooth), then send your command

That's it.

For me 100% successfull commands, time between command and moving the lock = 4 to 6 seconds (medium 5s)

Have fun !

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

3 participants