解决cloudflare worker遇到failed to dial to (wss://): 200 OK > websocket: bad handshake 的问题

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部署,使用网页面板不行。

之后在wrangler.toml里面添加compatibility_date = "2023-12-01"部署即可。大概日期随便填吧。

### 解决Ubuntu系统中设置中文时出现的Failed to fetch错误 #### 更改软件源地址 当遇到`Failed to fetch`错误时,通常是因为默认使用的软件仓库服务器响应缓慢或不可达造成的。对于中国用户来说,可以尝试更换成国内的镜像站点来提高下载速度并解决问题[^2]。 例如,将 `/etc/apt/sources.list` 文件中的官方源替换为中国科学技术大学(CSTC)、阿里云或其他可靠的国内镜像站: ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak # 备份原文件 sudo sed -i 's@http://archive.ubuntu.com@https://mirrors.aliyun.com@g' /etc/apt/sources.list sudo sed -i 's@http://security.ubuntu.com@https://mirrors.aliyun.com@g' /etc/apt/sources.list ``` 上述命令会把所有的 `archive.ubuntu.com` 和 `security.ubuntu.com` 替换成阿里的HTTPS链接形式。 #### 更新DNS配置 如果更改软件源后仍存在连接问题,则可能是由于 DNS 配置不当引起的。可以通过编辑 `/etc/resolv.conf` 来指定更稳定的公共DNS服务提供商,比如Google Public DNS 或 Cloudflare 的免费DNS服务[^4]: ```bash echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null echo "nameserver 1.1.1.1" | sudo tee -a /etc/resolv.conf > /dev/null ``` 为了防止修改被覆盖,在某些情况下可能还需要安装 `resolvconf` 工具,并调整其配置以保持自定义设置: ```bash sudo apt install openresolv sudo systemctl enable resolvconf.service ``` #### 执行更新操作 完成以上两步之后,再次运行以下命令来进行系统的全面刷新与升级: ```bash sudo apt clean all && sudo apt update && sudo apt upgrade -y ``` 通过这些措施应该能够有效解决网络环境差异而导致的 `Failed to fetch` 类型错误,从而顺利完成Ubuntu系统的汉化过程以及后续的应用程序安装工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值