iotile / coretools

Core python tools for building and using IOTile based devices
GNU General Public License v3.0
14 stars 7 forks source link

cannot connect after disconnect failure #958

Closed JKHeadley closed 4 years ago

JKHeadley commented 4 years ago

This is from the context of using HardwareManager with the Factory Desktop app. The process I use to reproduce is:

1) Connect to an AP 2) Turn off AP (remove power) 3) Disconnect from AP (fails) 4) Connect to AP or any other device (fails due to "already connected")

See the logs below:

DEBUG:iotile_transport_bled112.bled112:Found BLED112 device at /dev/cu.usbmodem11
INFO:iotile_transport_bled112.bled112:Using first available BLED112 adapter at /dev/cu.usbmodem11
WARNING:iotile_transport_bled112.bled112:pycryptodome is not installed, encrypted v2 broadcasts will be dropped.
INFO:iotile_transport_bled112.bled112:BLED112 adapter supports 3 connections
DEBUG:iotile.core.utilities.async_tools.event_loop:Starting event loop
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:iotile.core.utilities.async_tools.event_loop:Starting loop in background thread
DEBUG:iotile.core.utilities.async_tools.event_loop:Added primary task LegacyAdapter (BLED112Adapter)
DEBUG:iotile.core.utilities.async_tools.event_loop:Added subtask periodic task for BLED112Adapter to parent LegacyAdapter (BLED112Adapter)
ListVisibleDevices: 
Connecting: slug: "0x3039"

INFO:iotile.core.hw.transport.adapter.async_wrapper:Inside connect, conn_id=0, conn_string=88:6B:0F:66:A7:50
INFO:iotile_transport_bled112.bled112_cmd:Connected to device 50:A7:66:0F:6B:88 with interval=6, timeout=100, latency=0
WARNING:iotile_transport_bled112.bled112:Authentication check failed, user may not be able to send RPCs or use device proxy
INFO:iotile_transport_bled112.bled112:Total time to connect to device: 0.396 (0.035 enumerating services, 0.361 enumerating chars)
GetNetworkInfo: 
DEBUG:iotile.core.hw.hwmanager:Short name matched proxies found: [<class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>]
DEBUG:iotile.core.hw.hwmanager:Found a proxy without ModuleVersion info: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>
DEBUG:iotile.core.hw.hwmanager:Best proxy found: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'> with base version 0.0.0
DEBUG:iotile.core.hw.hwmanager:Short name matched proxies found: [<class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>]
DEBUG:iotile.core.hw.hwmanager:Found a proxy without ModuleVersion info: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>
DEBUG:iotile.core.hw.hwmanager:Best proxy found: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'> with base version 0.0.0
DEBUG:iotile.core.hw.hwmanager:Short name matched proxies found: [<class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>]
DEBUG:iotile.core.hw.hwmanager:Found a proxy without ModuleVersion info: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>
DEBUG:iotile.core.hw.hwmanager:Best proxy found: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'> with base version 0.0.0
DEBUG:iotile.core.hw.hwmanager:Short name matched proxies found: [<class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>]
DEBUG:iotile.core.hw.hwmanager:Found a proxy without ModuleVersion info: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>
DEBUG:iotile.core.hw.hwmanager:Best proxy found: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'> with base version 0.0.0
DEBUG:iotile.core.hw.hwmanager:Short name matched proxies found: [<class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>]
DEBUG:iotile.core.hw.hwmanager:Found a proxy without ModuleVersion info: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>
DEBUG:iotile.core.hw.hwmanager:Best proxy found: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'> with base version 0.0.0
DEBUG:iotile.core.hw.hwmanager:Short name matched proxies found: [<class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>]
DEBUG:iotile.core.hw.hwmanager:Found a proxy without ModuleVersion info: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'>
DEBUG:iotile.core.hw.hwmanager:Best proxy found: <class 'arch_node_tasks.node_config.network_config_proxy.NetworkConfigTileProxyObject'> with base version 0.0.0
WARNING:iotile_transport_bled112.bled112:Disconnection event, handle=0, reason=0x208, state=connected
INFO:iotile.core.hw.transport.adapterstream:Connection to device 88:6B:0F:66:A7:50 was interrupted
INFO:iotile_transport_bled112.bled112:Restarting scan for devices
INFO:iotile_transport_bled112.bled112:Finished restarting scan for devices
Disconnecting: 
ERROR:__main__:type: "DeviceAdapterError"
reason: "Operation disconnect on conn 0 failed because Invalid connection_id"
params: "{\"reason\": \"Invalid connection_id\", \"operation\": \"disconnect\", \"conn_id\": 0}"
Traceback (most recent call last):
  File "src/factory_companion_server.py", line 155, in Disconnect
  File "src/factory_app_controller.py", line 51, in wrapper
  File "src/factory_app_controller.py", line 153, in disconnect
  File "iotile/core/hw/hwmanager.py", line 285, in disconnect
  File "iotile/core/hw/transport/adapterstream.py", line 243, in disconnect
  File "iotile/core/utilities/async_tools/event_loop.py", line 540, in run_coroutine
  File "concurrent/futures/_base.py", line 435, in result
  File "concurrent/futures/_base.py", line 384, in __get_result
  File "iotile/core/hw/transport/adapter/async_wrapper.py", line 155, in disconnect
  File "iotile/core/hw/transport/adapter/async_wrapper.py", line 227, in _raise_error
iotile.core.hw.exceptions.DeviceAdapterError: DeviceAdapterError: Operation disconnect on conn 0 failed because Invalid connection_id
Additional Information:
reason: Invalid connection_id
operation: disconnect
conn_id: 0
ListVisibleDevices: 
Connecting: slug: "0x3039"

ERROR:__main__:type: "HardwareError"
reason: "Cannot connect when we are already connected"
params: "{}"
Traceback (most recent call last):
  File "src/factory_companion_server.py", line 140, in Connect
  File "src/factory_app_controller.py", line 51, in wrapper
  File "src/factory_app_controller.py", line 147, in connect
  File "</Users/jheadley/Documents/GitHub/iotile-factory-companion/electron/factory_companion_server/dist/factory_companion_server/decorator.pyc:decorator-gen-24>", line 2, in connect
  File "typedargs/utils.py", line 32, in _check_and_execute
  File "iotile/core/hw/hwmanager.py", line 270, in connect
  File "iotile/core/hw/transport/adapterstream.py", line 177, in connect
iotile.core.exceptions.HardwareError: HardwareError: Cannot connect when we are already connected