ble2mqtt icon indicating copy to clipboard operation
ble2mqtt copied to clipboard

Application crashed when connection to Mosquitto lost

Open orzechszek opened this issue 2 years ago • 0 comments

In docker on rasbpi I'm getting application crash when it lost connectivity to mosquitto. Only restart helps.

ERROR: Connection lost. Will retry in 10 seconds. Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/aio_mqtt/client.py", line 204, in connect self._reader, self._writer = await aio.open_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/streams.py", line 48, in open_connection transport, _ = await loop.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection raise exceptions[0] File "/usr/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock await self.sock_connect(sock, address) File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect return await fut ^^^^^^^^^ File "/usr/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 1883) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 970, in _connect_forever mqtt_connection = await aio.wait_for(self._mqtt_client.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for return fut.result() ^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/aio_mqtt/client.py", line 207, in connect raise ConnectFailedError() from e aio_mqtt.exceptions.ConnectFailedError ERROR: Disconnect from MQTT broker error ERROR: Connection lost. Will retry in 10 seconds. Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/aio_mqtt/client.py", line 204, in connect self._reader, self._writer = await aio.open_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/streams.py", line 48, in open_connection transport, _ = await loop.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection raise exceptions[0] File "/usr/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock await self.sock_connect(sock, address) File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect return await fut ^^^^^^^^^ File "/usr/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 1883) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 970, in _connect_forever mqtt_connection = await aio.wait_for(self._mqtt_client.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for return fut.result() ^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/aio_mqtt/client.py", line 207, in connect raise ConnectFailedError() from e aio_mqtt.exceptions.ConnectFailedError ERROR: Disconnect from MQTT broker error INFO: Connected to localhost WARNING: Restarting bluetoothd... ERROR: <Task finished name='Task-1458' coro=<Ble2Mqtt.scan_devices_task() done, defined at /usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py:881> exception=FileNotFoundError(2, 'No such file or directory')> stopped unexpectedly Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 178, in handle_ble_exceptions yield File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 896, in scan_devices_task await aio.wait_for(scanner.start(), 10) File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for return fut.result() ^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/bleak/__init__.py", line 182, in start await self._backend.start() File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/scanner.py", line 191, in start self._stop = await manager.active_scan( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 368, in active_scan assert_reply(reply) File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply raise BleakDBusError(reply.error_name, reply.body) bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 890, in scan_devices_task async with handle_ble_exceptions(self._hci_adapter): File "/usr/lib/python3.11/contextlib.py", line 222, in __aexit__ await self.gen.athrow(typ, value, traceback) File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 181, in handle_ble_exceptions await restart_bluetooth(adapter) File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 146, in restart_bluetooth proc = await aio.create_subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/subprocess.py", line 218, in create_subprocess_exec transport, protocol = await loop.subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 1694, in subprocess_exec transport = await self._make_subprocess_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/unix_events.py", line 207, in _make_subprocess_transport transp = _UnixSubprocessTransport(self, protocol, args, shell, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_subprocess.py", line 36, in __init__ self._start(args=args, shell=shell, stdin=stdin, stdout=stdout, File "/usr/lib/python3.11/asyncio/unix_events.py", line 810, in _start self._proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.11/subprocess.py", line 1917, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'hciconfig' ERROR: Connection lost. Will retry in 10 seconds. Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 178, in handle_ble_exceptions yield File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 896, in scan_devices_task await aio.wait_for(scanner.start(), 10) File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for return fut.result() ^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/bleak/__init__.py", line 182, in start await self._backend.start() File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/scanner.py", line 191, in start self._stop = await manager.active_scan( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 368, in active_scan assert_reply(reply) File "/usr/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply raise BleakDBusError(reply.error_name, reply.body) bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 992, in _connect_forever await self._run_device_tasks(mqtt_connection.disconnect_reason) File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 964, in _run_device_tasks await handle_returned_tasks(*finished) File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 114, in handle_returned_tasks await task_for_raise File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 890, in scan_devices_task async with handle_ble_exceptions(self._hci_adapter): File "/usr/lib/python3.11/contextlib.py", line 222, in __aexit__ await self.gen.athrow(typ, value, traceback) File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 181, in handle_ble_exceptions await restart_bluetooth(adapter) File "/usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py", line 146, in restart_bluetooth proc = await aio.create_subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/subprocess.py", line 218, in create_subprocess_exec transport, protocol = await loop.subprocess_exec( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 1694, in subprocess_exec transport = await self._make_subprocess_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/unix_events.py", line 207, in _make_subprocess_transport transp = _UnixSubprocessTransport(self, protocol, args, shell, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_subprocess.py", line 36, in __init__ self._start(args=args, shell=shell, stdin=stdin, stdout=stdout, File "/usr/lib/python3.11/asyncio/unix_events.py", line 810, in _start self._proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.11/subprocess.py", line 1917, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'hciconfig' /usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py:867: FutureWarning: BLEDevice.rssi is deprecated and will be removed in a future version of Bleak, use AdvertisementData.rssi instead if device.rssi: /usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py:869: FutureWarning: BLEDevice.rssi is deprecated and will be removed in a future version of Bleak, use AdvertisementData.rssi instead reg_device.rssi = device.rssi INFO: Connected to localhost WARNING: Restarting bluetoothd... ERROR: <Task finished name='Task-1472' coro=<Ble2Mqtt.scan_devices_task() done, defined at /usr/lib/python3.11/site-packages/ble2mqtt/ble2mqtt.py:881> exception=FileNotFoundError(2, 'No such file or directory')> stopped unexpectedly

orzechszek avatar Aug 28 '23 20:08 orzechszek