Quote
When Cloudflare terminates (or you press F5/refresh on the browser), a state of 1001 occurs. When I close a socket (only 3 instances, 1- as you stated, 2nd connection, 2- ladder reset, 3- shutdown sequence), I always issue state 1000. All of these disconnects are either 1006 (network fault), or 1001 (Cloudflare restarting their proxy).
Taken from a discussion I had with the man himself in 2018 after the rewrite
edit:
also:
https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSocketsQuote
Technical note
When Cloudflare releases new code to its global network, we may restart servers, which terminates WebSockets connections.
This post was edited by Meridius on Feb 7 2020 07:05am