JoelBender / BACpypes3

BACnet communications library
50 stars 10 forks source link

Invalid state transition from COMPLETED to AWAIT_CONFIRMATION #57

Open JoelBender opened 3 months ago

JoelBender commented 3 months ago

Every once in a while this exception is raised. Upon investigation, indication() is being called from await_confirmation_timeout() here as if the request is coming from the application but that's not actually true. The state is COMPLETED, so that means that the response was received but the timeout task wasn't canceled. The Task object that returned by ensure_future() should be canceled, or better associated with the _timer_handle().

@ChristianTremblay

ChristianTremblay commented 2 months ago
Task exception was never retrieved
future: <Task finished name='Task-38353' coro=<ClientSSM.await_confirmation_timeout() done, defined at /home/ctremblay/.local/lib/python3.10/site-packages/bacpypes3/appservice.py:836> exception=RuntimeError('invalid state transition from COMPLETED to AWAIT_CONFIRMATION')>
Traceback (most recent call last):
  File "/home/ctremblay/.local/lib/python3.10/site-packages/bacpypes3/appservice.py", line 852, in await_confirmation_timeout
    await self.indication(self.segmentAPDU)
  File "/home/ctremblay/.local/lib/python3.10/site-packages/bacpypes3/appservice.py", line 536, in indication
    self.set_state(AWAIT_CONFIRMATION, self.apduTimeout)
  File "/home/ctremblay/.local/lib/python3.10/site-packages/bacpypes3/appservice.py", line 404, in set_state
    SSM.set_state(self, newState, timer)
  File "/home/ctremblay/.local/lib/python3.10/site-packages/bacpypes3/appservice.py", line 216, in set_state
    raise err
RuntimeError: invalid state transition from COMPLETED to AWAIT_CONFIRMATION

that was on Gitter but it's probably better to put that here as reference

This is running on a Raspberry Pi, Ubuntu 64bit