Cloudflare Websocket Proxy error with recent Edge update
Using cloudflare for my website, worked perfect for years and I haven't made any changes to my server or code in months.
Yesterday an update to CF edge started choking on websocket responses from my server, I get this error (Firefox):
HTTP/1.1 502 Bad Gateway
Date: Wed, 14 May 2025 20:24:57 GMT
Content-Length: 68
Connection: keep-alive
Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Referrer-Policy: same-origin
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Proxy-Status: Cloudflare-Proxy;error=http_protocol_error
Note the Cloudflare-Proxy error.
I run my site on a dedicated VPS and CF only serves as proxy.
In my nginx access log this particular request appears as 101 status, and my node app logged a successful/accepted request. I am using the 'ws' lib in nodejs, and I have a verifyClient handler to either accept or deny (401) upgrades.
Nothing on my end indicates anything is wrong, but CF still returns 502 to anyone trying to connect to my site's wss.
On my CF dashboard I can also see "Edge Status Code" view spikes with 502's any time I turn on proxy again, and it used to work just fine 2 days ago without any changes on my end.
I tried disabling perMessageDeflate to see if that was tripping up the Edge runtime, didn't work.
Tried disabling chunking and compression on nginx for my wss route, didn't work.
Tried disabling HTTP2.0 to origin in CF panel, didn't work. (I see all the reqs are 1.1 anyway)
Edit: Forgot to mention that I disabled CF proxying for the time being so my business could operate. And it happens that when CF is not proxying the requests, websockets start working again.
If more info is needed, just let me know. Thank you!
Yesterday an update to CF edge started choking on websocket responses from my server, I get this error (Firefox):
HTTP/1.1 502 Bad Gateway
Date: Wed, 14 May 2025 20:24:57 GMT
Content-Length: 68
Connection: keep-alive
Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Referrer-Policy: same-origin
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Proxy-Status: Cloudflare-Proxy;error=http_protocol_error
Note the Cloudflare-Proxy error.
I run my site on a dedicated VPS and CF only serves as proxy.
In my nginx access log this particular request appears as 101 status, and my node app logged a successful/accepted request. I am using the 'ws' lib in nodejs, and I have a verifyClient handler to either accept or deny (401) upgrades.
Nothing on my end indicates anything is wrong, but CF still returns 502 to anyone trying to connect to my site's wss.
On my CF dashboard I can also see "Edge Status Code" view spikes with 502's any time I turn on proxy again, and it used to work just fine 2 days ago without any changes on my end.
I tried disabling perMessageDeflate to see if that was tripping up the Edge runtime, didn't work.
Tried disabling chunking and compression on nginx for my wss route, didn't work.
Tried disabling HTTP2.0 to origin in CF panel, didn't work. (I see all the reqs are 1.1 anyway)
Edit: Forgot to mention that I disabled CF proxying for the time being so my business could operate. And it happens that when CF is not proxying the requests, websockets start working again.
If more info is needed, just let me know. Thank you!