-
Notifications
You must be signed in to change notification settings - Fork 1
InvalidStateError in _on_msg #6
Comments
@CmpCtrl hey! I'm wondering if you have seen an error like this in your usage? I get it over a period of time, like 15-30 minutes, every couple of days. |
Yes, i see a similar symptom. I think its happening when the server forcefully closes the connection, but i don't know why that happens sometimes. I haven't looked into how to handle that better in the error checking either, it does seem to recover but yea takes 15 min or so. I probably wont have a chance to look at it real soon, but i'll try to review it at some point. Im not sure if we'll be able to help the root cause, but should be able to handle the error more elegantly i'd think. |
I've seen it in 2 cases. one does look like the server closing the connection. the other looks like its related to receiving 2 events really close to each other. here's another log with my on message handler log included (it's the "New measurement received") one. notice how two publishes come in (09:34:26 and 09:34:27), then there is the error and one successful message at 09:34:28. So I have to imagine one of the publishes is hitting the error and one is being handled. It feels like they are both trying to be handled by the msg handler at the same time but one one is able to do Nothing actually fails from this, it immediately starts receiving events again I might just put in some code to handle this. I can just check to make sure the result hasn't been set yet.
|
Yeah I was able to reproduce this in the Paho MQTT asyncio example by publishing two events at the same time. Looking for a fix now. |
interesting. yea that example is where i got the framework for that part of the code. I thought it was needed to work with the asyncio parts of your existing library, and that it could handle pretty high rate msgs. But, maybe thats not a good approach or not using the paho-mqtt library correctly. |
yeah normally it handles it fine but there's some weird edge case where it's hitting this. it might be an incorrect use of asyncio somewhere but nothing stands out to me. I'm just going to put in logic to handle this where the message will just be skipped. |
I'm seeing error logs from the Home Assistant integration that are coming from this library
Example:
See mjmeli/ha-duke-energy-gateway#36 for more context
I'm wondering if it has to do with the messages being received so close together. The timestamp only has second precision but they might be <1 sec apart.
The text was updated successfully, but these errors were encountered: