lanqian528 / chat2api

A service that can convert ChatGPT on the web to OpenAI API format.
MIT License
1.89k stars 377 forks source link

OpenAI升级了wss连接检查,导致403 #26

Closed yuanzhanghu closed 5 months ago

yuanzhanghu commented 5 months ago

wscat --connect wss://chatgpt-async-webps-prod-southcentralus-5.chatgpt.com/client/hubs/conversations?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NoYXRncHQtYXN5bmMtd2VicHMtcHJvZC1zb3V0aGNlbnRyYWx1cy01LndlYnB1YnN1Yi5henVyZS5jb20vY2xpZW50L2h1YnMvY29udmVyc2F0aW9ucyIsImlhdCI6MTcxNDE4NDY2NSwiZXhwIjoxNzE0MTg4MjY1LCJzdWIiOiJ1c2VyLVNFR2JVZE53eW93VjRKS2tKSnR3MHUycSIsInJvbGUiOlsid2VicHVic3ViLmpvaW5MZWF2ZUdyb3VwLnVzZXItU0VHYlVkTnd5b3dWNEpLa0pKdHcwdTJxIl0sIndlYnB1YnN1Yi5ncm91cCI6WyJ1c2VyLVNFR2JVZE53eW93VjRKS2tKSnR3MHUycSJdfQ.lbHLjqxv6b2zGqGEHlX2vhtyz2QeSL_2ra20pVL9g3A error: Unexpected server response: 403

使用curl_cffi websocket都不能解决: curl_cffi.curl.CurlError: Failed to perform, curl: (22) Refused WebSockets upgrade: 403. See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

看来需要进一步研究为什么导致403。

yuanzhanghu commented 5 months ago

抓包看,应该和__cf_bm相关: This cookie is part of Cloudflare’s Bot Management service and is used to distinguish human visitors from bots. It helps manage incoming traffic that matches criteria associated with bots, and is also used to mitigate DDoS attacks and abusive bots, especially for website forms like login pages and search functions. This cookie usually has a very short lifetime to ensure it only affects the traffic session it was intended for.

lanqian528 commented 5 months ago

进交流群说吧https://t.me/chat2api

yuanzhanghu commented 5 months ago

这个应该还是JA3 TLS fingerprint的问题。 但是curl_cffi的websocket不好用。

yuanzhanghu commented 5 months ago

鉴于 curl_cffi的websocket有问题, 准备新建一个chatgpt websocket的专用api, 以便后续我们可以使用async 的wss generator。 目前开发中: https://github.com/yuanzhanghu/gpt_wss_api

lanqian528 commented 5 months ago

大佬牛逼

lanqian528 commented 5 months ago

貌似不再403了