Well, butter my bum and call me a biscuit! Sir, you are a genius, please send my warmest regards to your dodgy wifi router!
That's it, I've managed to reproduce the issue and it is caused by WiFi fluctuation.
I had a bit of trouble killing the wifi to the little ESP32-C3, I have a mesh network around the house so even killing two routers didn't work (have 6) . Then I brought out the big guns and tried enclosing the little bugger in metal, starting with a small metal box then a soup can and finally gave up when a combo of cake tin and large cooking pot didn't do the trick!
I mean seriously, how on earth that little ceramic antenna can pick up the signal so well!?
Long story short, in the end I've tethered it to my phone and then stoped the wifi and bam, same messages and slightly different number from ChipChop but in the similar range.
So, the story with the library code. The wifi check that you use in your main loop is actually not required, it's only there in that example just to show a good coding practice because is saves a bit of work for the processor.
Technically you can update the statuses at any time (even non-stop) and the ChipChop library will still handle all the timings and the websockets will do their own connection checks. Have a looksie inside the "smart-button" example, there's no checks at all but the requests are still sent in correct intervals i.e. like a heartbeat.
That weird long number I have no idea, probably some wonky c++ maths with negative integers, easy to fix now that I know what to look for.
But, I do know now that the WebSocket connection check gets incorrect report back from the underlying Espressiff sdk. It's not the WiFi at all but the http client layer that incorrectly reports back that there is no client connection with the server and kills a completely valid connection and sometimes keeps doing it in a loop.
Now, thanks to your detective work and knowing that this is all caused by a "hiccup" in the wifi client I can potentially do some fail safe checks and try to dispose of the entire wifi client and restart the wifi or maybe dispose of the websockets or something like that. Alternatively I can maybe give an option (i.e. aggressive keep alive) and restart the entire ESP if the connection is hanging for too long? (that could maybe force the reconnection and on an ESP a restart/reconnect would take maybe 1-2 seconds)
Thank very much for this find, this has potentially saved me a week of going in circles.