destination > common/retry: [transport/internet/websocket: failed to dial WebSocket > transport/internet/websocket: failed to dial to (wss://cw.fjh1997.top/): 200 OK > websocket: bad handshake] > common/retry: all retry attempts failed
开发的时候遇到这个问题,奈何浏览器抓不了websocket的握手包,正常握手包是101状态码的http数据包,但是实际上返回了200状态码的数据包。试了下wscat也不行,看来只能用大名鼎鼎的burpsuite了。
抓包显示,
Error: To use the new ReadableStream() constructor, enable the
streams_enable_constructors compatibility flag. Refer to the docs for
more information:
https://developers.cloudflare.com/workers/platform/compatibility-dates/#compatibility-flags
由于我用了new ReadableStream()这个函数,所以需要设置flag,而根据上述文档,该flag只有通过wrangler部署,使用网页面板不行。文章来源:https://www.toymoban.com/news/detail-839919.html
之后在wrangler.toml里面添加compatibility_date = "2023-12-01"
部署即可。大概日期随便填吧。文章来源地址https://www.toymoban.com/news/detail-839919.html
到了这里,关于解决cloudflare worker遇到failed to dial to (wss://): 200 OK > websocket: bad handshake 的问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!