koishijs / chatgpt-bot

AI conversation based on ChatGPT | 基于 ChatGPT 的 AI 对话机器人
https://chatgpt.koishi.chat
MIT License
70 stars 13 forks source link

Always invaild token in new version #6

Closed pandadtdyy closed 1 year ago

pandadtdyy commented 1 year ago

使用版本:1.2.1 on koishi@4.10.4 情况:token填写后始终提示invaild token,同一token复制入其他脚本(chatGPT-vscode)可正常使用,抓包后发现未正常发送加密get请求,而是向 http://chat.openai.com:443 发送了请求,更换回1.1.x正常使用。

image

MaikoTan commented 1 year ago

It looks like the screenshot you posted was expected in the current version, the plugin requests the URL http://chat.openai.com:443/api/auth/session to obtain the access token. The abnormal part is that every HTTP request here returns 307 Temporary Redirect instead of 200 OK, is there something that rewrites your HTTP request in your network? Also, I tested it on my side, it worked well unless the server was down again.

pandadtdyy commented 1 year ago

It looks like the screenshot you posted was expected in the current version, the plugin requests the URL http://chat.openai.com:443/api/auth/session to obtain the access token. The abnormal part is that every HTTP request here returns 307 Temporary Redirect instead of 200 OK, is there something that rewrites your HTTP request in your network? Also, I tested it on my side, it worked well unless the server was down again.

I think it should post to the https://chat.openai.com, so it can not work. I use the proxyAgent setting because my server can not connect to openai directly. I remove proxy setting then it works.

MaikoTan commented 1 year ago

Can you tell me what is the proxy software and which protocol (HTTP / Socks, etc) you are using? I assume the problem happens on your proxy side. We are using Axios for HTTP requesting, and it works well on my side w/ or w/o the proxyAgent settings.

MaikoTan commented 1 year ago

Also, you might needn't the proxyAgent, see https://github.com/koishijs/chatgpt-bot/issues/5#issuecomment-1340311577

pandadtdyy commented 1 year ago

Can you tell me what is the proxy software and which protocol (HTTP / Socks, etc) you are using? I assume the problem happens on your proxy side. We are using Axios for HTTP requesting, and it works well on my side w/ or w/o the proxyAgent settings.

I use clash with HTTP protocol, I try to replace to socks, then it works. Maybe The bug is on HTTP proxy.

Also, you might needn't the proxyAgent, see #5 (comment)

Oh, I can connect directly on China Telecom, but can not connect directly on Tencent Cloud Shanghai. Lighthouse servers have the suck network to connect abroad.

pandadtdyy commented 1 year ago

I think it can be closed because it is a upstream bug on axios. Axios did not support HTTPS requests over HTTP proxies. See https://github.com/axios/axios/issues/4531