technyon / nuki_hub

Use an ESP32 as a Hub between a NUKI Lock and your smarthome.
MIT License
526 stars 40 forks source link

"Client nukihub already connected, closing old connection" with v7 #87

Closed mahikeulbody closed 1 year ago

mahikeulbody commented 1 year ago

Hi,

I upgraded my nuki hub with the last firmware. Now I have many :

Client nukihub already connected, closing old connection New client connected from 192.168.0.227:58397 as nukihub"

With the previous version (v6.11) I had some reconnections because of malformed mqtt packet. It seems I have not anymore these malformed packet, only these new messages.

Mincka commented 1 year ago

I tried a lot of different Wi-Fi settings on/off (20/40, OFDMA, PMF, Smart Connect...). Same results.

mahikeulbody commented 1 year ago

Same situation here. I stay on an uptime average of 2 ou 3 hours. Since the restart is fast, it is not really a problem. But, of course, it would be fine to understand what is the cause of these crashes.

No change with 8.1 but it is normal since this release was to correct another problem.

mahikeulbody commented 1 year ago

@Mincka It is probably not relevant but how do you flash the first time your device : via the web installer, via the Espressif Flash Download Tool or via the command line esptool.py --chip esp32 --port /dev/ttyUSB0 [...] described into the readme ?

I flashed it via the esptool.py command line.

Mincka commented 1 year ago

I tried both esptool GUI and web installer and it made no difference.

mahikeulbody commented 1 year ago

Yesterday, I made a factory reset of my ESP and then I reflashed it with fw8.2. I plug-in it to a new usb power supply* with a new usb cable. I did not change any default setting of the fw (except of course the settings needed to connect to my mqtt broker). HA discovered it again (except the sensor door (???), please see my post on the HA forum) and I crossed my fingers but without much hope. This morning the uptime is > 910 and continues to grow (I never reached more than 400 before). I keep crossing my fingers but hope has increased.

I don't know what was the decisive change (if any) and of course I will wait a little more before to consider my problem solved.

mahikeulbody commented 1 year ago

It seems there is no more problem on my side : image

alexdelprete commented 1 year ago

It seems there is no more problem on my side :

so you think it was the power supply? or the reset+flash?

mahikeulbody commented 1 year ago

Or both. What else ? I will put back the previous power supply in a few days to see what happens. Ah, I almost forgot, I also updated the fw of the lock.

alexdelprete commented 1 year ago

I will put back the previous power supply in a few days to see what happens.

that's a good idea, it allows us to exclude an option.

Mincka commented 1 year ago

Do you register the nuki_hub as app or bridge? image

mahikeulbody commented 1 year ago

As I said in my post "I did not change any default settings of the fw (except of course the settings needed to connect to my mqtt broker)". So I registered as bridge.

mahikeulbody commented 1 year ago

so you think it was the power supply? or the reset+flash?

@alexdelprete It is also theoretically possible that some non default settings could lead to the crashes.

Mincka commented 1 year ago

Thanks for the confirmation. I currently have good results after reset + 8.3 but I also changed few other things so I'm not sure yet. I updated my second ESP this morning with reset + 8.3 without changing power supply and cable. I'll see if it's also more stable.

The only thing that changed in the settings for me is registering as App instead of Bridge. If you never used "Register as Bridge", I think it's safe to exclude non-default settings. I also add reboots without changing other settings (except this one) in the past.

mahikeulbody commented 1 year ago

What do you mean saying "good results" ? No more restart or "just" longer uptime ?

Btw, since my "global" reset, my uptime is almost 2500 without any restart.

Mincka commented 1 year ago

No reboot since erase + installation of 8.3. image

No reboot also on the other ESP I erased + reinstalled this morning, but still a little bit too soon to be sure for this one.

mahikeulbody commented 1 year ago

Good news ! Now you have to wait the uptime goes much higher than your previous "giant" uptime of 1500 to be sure that the problem is gone.

Mincka commented 1 year ago

If both stay like this for 5 more hours, it will be enough to say that the issue is gone. In that case, it means it was related to buggy flashing and/or OTA updates.

Not related to the ESP model, the power supply, the cable, the Wi-Fi...

mahikeulbody commented 1 year ago

and/or OTA updates.

Indeed, since I had to "serial connect" my ESP to reset it, I flashed v8.2 with the ESP still connected with the usb cable, not through OTA. So, may be... Do the fw auto-control itself the CRC ?

mahikeulbody commented 1 year ago

After to reach 2700, I decided to back to the previous power supply (and its cable) to see what happens. Absolutely no other change made.

Mincka commented 1 year ago

I don't want to fiddle with my setup anymore right now because it's stable. Still no reboot for both locks. For the next version of Nuki Hub, I'll update using OTA and we will see if it reboots again.

Mincka commented 1 year ago

Stability confirmed. image Now OTA to 8.4.

mahikeulbody commented 1 year ago

After to reach 2700, I decided to back to the previous power supply (and its cable) to see what happens. Absolutely no other change made.

The previous power supply restarted with an uptime of 630 this night (remember : nuki hub was at 2700 with the new power supply when I decided to stop it myself to try the previous power supply). So it seems that the previous power supply was involved in the problem. But may be it is not alone involved since the best score with it before was only 400. I will let it running without any change (staying on v8.3).

mahikeulbody commented 1 year ago

So it seems that the previous power supply was involved in the problem.

or not... After the restart at 630, the uptime reached 1200 and continues growing...

Finally, the only obvious thing is that the uptime is without comparison with the one before. It seems impossible to believe that the problem comes from the power supply (or only from the power supply). So it could be the erase/reset before re-flashing, and/or the re-flashing through usb cable instead OTA, and/or default settings less prone to lead to crashes than my previous settings (lower probability of race conditions, for example ; I don't know if that make sense for this fw).

In addition to a perfect or almost perfect uptime now, I also notice that the battery of my lock does not drain quickly anymore as in the previous configuration ; it seems that I am back to the consumption that I had with the official bridge. This observation is probably premature after only three days but I am still at 100% whereas with the previous configuration I was losing 2.5% per day !

technyon commented 1 year ago

If you gave many reboots, the ESP will query the lock after every reboot, which needs at least three connections:

mahikeulbody commented 1 year ago

Indeed, there were very roughly 20 restarts/day. It seems to you enough to explain such a difference ?

mahikeulbody commented 1 year ago

Since nobody seems to complain anymore about this problem, I think we can close this issue.