-
Notifications
You must be signed in to change notification settings - Fork 24
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
lost mqtt connexion? #176
Comments
I can confirm that of the docker container fix the problem. Any insight on what happen is happening? |
Hi @vbarrier,
What you mean with docker container fix? |
Hi I'm using the latest version of TeslMateApi (1.14) and MQTT version is 2. It seems that the api lost connexion or doesn't take any more mqtt updates..
About docker container, I mean, that a restart of the docker container fix the issue for couple hours.. |
Hi @vbarrier, have you done some more debugging for this issue? I currently experiencing the exact same behavior. |
Hi, still facing the bug I ended up restarting the container every 4 hours. :( |
I looks like connections should be re-established... teslamateapi/src/v1_TeslaMateAPICarsStatus.go Lines 134 to 135 in 27d2044
but also.. it looks like there are some some handlers that could be better utilized at a minimum for the purpose of logging... for example.... ... again.. might be worth adding some logging.. then we may be able to better determine the nature of the failure. |
I have forked the project and tried to add some debugging output as suggested. This version is running now inside a docker container. We will see if the problem occurs again, then I will keep you informed. If you look in my forked sourcecode you may see that I am not a go developer ;-). |
The problem occurred again. For me it looks like there is no MQTT issue. I cannot see any log entries regarding lost connections or reconnecting. But if I call the status api end point I get:
In the TeslaMate UI I see the state as "online" not "suspended". I have tried to restart the my MQTT-Server (mosquitto in this case) and got the following messages in the logfile:
So the "extended logging" seems to work. Maybe there is a problem with the cache? |
Another example: Maybe we have to "resubscribe" the topics after a reconnect? Does anybody know? |
I also think this is a cache problem somewhere. I'm querying the teslamate-api every minutes and after sometime not working anymore. The restart thing remove all cache.. I will try to have a mirror setup as I don't want to break my current production setup. |
I have another point found and currently do some tests with this patch implemented: virusbrain@3ce7126 Test is currently ongoing and as I am not a MQTT expert I am not sure which side effects this patch would produce... But if it will help I may be able to make the code a bit more fancy and create a pull request for this. |
If I read your response correctly, I should be able to re-create this scenario by restarting the MQTT service, is that correct? |
This should be the case. As already mentioned I do currently running a version with |
Just FYI: With So from my point of view we do have two possibilities:
|
This is really good information, thank you for taking the time to troubleshoot and document. I will see what I can do to make time this next week to dig in... I am inclined to say we should certainly be re-subscribing on re-connect... I would need to read up more on SetCleanSession. |
After reviewing/testing some... it looks like |
also considering returning 500 when mqtt is not connected... |
Test went well this morning. I was able to interrupt the connection between
|
Aren't we able to simply resubscribe to the mqtt topics after a reconnect occured? According to my understandig we just have to refactor the subscription part (https://github.com/LelandSindt/teslamateapi/blob/96d53a66dd30574a1f1d15a4d86f77766d9b5018/src/v1_TeslaMateAPICarsStatus.go#L151-L156) somehow that it can subscribe to the topics in a reconnecting-handler. Or do I miss something? |
I started down the re-subscribe path last night, but could not quite grok how it would best be done cleanly. ... I will have another look at it tonight. |
After reviewing this.. eclipse-paho/paho.mqtt.golang#22 I made these changes... LelandSindt@59784a7 they look good in simple/synthetic tests, I will test again in the morning. |
Yeah, on the first look this looks promising! I will setup a docker container to test this too. |
Thank you for your time & testing I will do this too this evening |
After K8s started a new looks good to me, y'all have any feedback or concerns? |
@virusbrain do you want the honour of issuing the PR? --- if not let me know, I can put it together right quick. |
I would really be happy issuing the PR. I try to cleanup the MQTT_ClientID stuff and then open the PR. I think I have some time this evening. |
specific to MQTT_CLIENTID I should have mentioned I cleaned that up last night... Let me know if you have any questions/issues pulling my commits/changes in! |
Co-authored-by: Leland Sindt <[email protected]>
Hi! thank you for this great addon :)
However, I have a problem since I use it :(. It seems that the backend loose the connection with the Mosquitto server or doesn't not refresh the cached data.
I'm polling the api/v1/cars/*/status every 1 minutes to populate a tracking database.
The text was updated successfully, but these errors were encountered: