zhayujie / chatgpt-on-wechat

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT-o1/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
https://docs.link-ai.tech/cow
MIT License
29.84k stars 7.88k forks source link

企业微信进行接收消息服务器配置时提示“服务器异常,请稍候再试” #2160

Closed ContrapunctusXIV closed 1 month ago

ContrapunctusXIV commented 1 month ago

前置确认

⚠️ 搜索issues中是否已存在类似问题

操作系统类型?

Linux

运行的python版本是?

python 3.10

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

other

复现步骤 🕹

测试个人微信通道可以使用后,根据文档配置企业微信相关参数,在配置“API接收消息”的“接收消息服务器配置”时点击确认

问题描述 😯

微信截图_20240718114844 服务器可以接收到请求,似乎也正常返回了,但是不知道什么原因无法通过企业微信的验证

终端日志 📒

root@chatbot-new1:~/chatgpt-on-wechat# python3 app.py
[DEBUG][2024-07-18 11:32:04][config.py:293] - [INIT] set log level to DEBUG
[INFO][2024-07-18 11:32:04][config.py:295] - [INIT] load config: {'open_ai_api_key': 'd1d*****b66', 'model': 'gpt-4o', 'proxy': '', 'single_chat_prefix': [''], 'single_chat_reply_prefix': '[bot] ', 'group_chat_prefix': ['@bot'], 'group_name_white_list': ['ChatGPT测试群', 'ChatGPT测试群2'], 'group_chat_in_one_session': ['ChatGPT测试群'], 'conversation_max_tokens': 4000, 'speech_recognition': False, 'group_speech_recognition': False, 'use_azure_chatgpt': True, 'open_ai_api_base': 'https://grgold-chatbot.openai.azure.com/', 'azure_deployment_id': 'gpt4o', 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。', 'subscribe_msg': '感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持角色扮演和文字冒险等丰富插件。\n输入{trigger_prefix}#help 查看详细指令。', 'dalle3_image_style': 'natural', 'dalle3_image_quality': 'hd', 'azure_openai_dalle_deployment_id': 'Dalle3', 'azure_openai_dalle_api_base': 'https://grgold-chatbot.openai.azure.com/', 'text_to_image': 'dall-e-3', 'image_proxy': False, 'image_create_prefix': ['画', '看', '找'], 'concurrency_in_session': 1, 'image_create_size': '256x256', 'group_chat_exit_group': False, 'expires_in_seconds': 3600, 'channel_type': 'wechatcom_app', 'wechatcom_corp_id': '***', 'wechatcomapp_token': '***', 'wechatcomapp_secret': 'aJe*****klk', 'wechatcomapp_agent_id': '1000016', 'wechatcomapp_aes_key': 'sNr*****kfB', 'wechatcomapp_port': 8887, 'debug': True}
[INFO][2024-07-18 11:32:04][config.py:219] - [Config] User datas loaded.
[DEBUG][2024-07-18 11:32:04][audio_convert.py:9] - import pysilk failed, wechaty voice message will not be supported.
[INFO][2024-07-18 11:32:04][wechatcomapp_channel.py:39] - [wechatcom] init: corp_id: ****, secret:****, agent_id: 1000016, token: ****, aes_key: ****
[INFO][2024-07-18 11:32:04][plugin_manager.py:50] - Loading plugins config...
[INFO][2024-07-18 11:32:04][plugin_manager.py:88] - Scaning plugins ...
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin linkai_v0.1.0 registered, path=./plugins/linkai
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin Godcmd_v1.0 registered, path=./plugins/godcmd
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin Role_v1.0 registered, path=./plugins/role
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin Dungeon_v1.0 registered, path=./plugins/dungeon
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin BDunit_v0.1 registered, path=./plugins/bdunit
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin Keyword_v0.1 registered, path=./plugins/keyword
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin Finish_v1.0 registered, path=./plugins/finish
[INFO][2024-07-18 11:32:04][plugin_manager.py:41] - Plugin Hello_v0.1 registered, path=./plugins/hello
chatgpt-tool-hub version: 0.5.0
[INFO][2024-07-18 11:32:05][plugin_manager.py:41] - Plugin tool_v0.5 registered, path=./plugins/tool
[INFO][2024-07-18 11:32:05][plugin_manager.py:41] - Plugin Banwords_v1.0 registered, path=./plugins/banwords
[DEBUG][2024-07-18 11:32:05][plugin_manager.py:179] - plugins.json config={'plugins': SortedDict({'Godcmd': {'enabled': True, 'priority': 999}, 'Keyword': {'enabled': True, 'priority': 900}, 'Banwords': {'enabled': False, 'priority': 100}, 'linkai': {'enabled': False, 'priority': 99}, 'tool': {'enabled': True, 'priority': 0}, 'Role': {'enabled': True, 'priority': 0}, 'Dungeon': {'enabled': True, 'priority': 0}, 'BDunit': {'enabled': False, 'priority': 0}, 'Hello': {'enabled': True, 'priority': -1}, 'Finish': {'enabled': True, 'priority': -999}}, sort_func=<lambda>, reverse=True)}
[DEBUG][2024-07-18 11:32:05][plugin.py:21] - loading plugin config, plugin_config_path=./plugins/godcmd/config.json, exist=True
[DEBUG][2024-07-18 11:32:05][plugin.py:28] - loading plugin config, plugin_name=Godcmd, conf={'password': '', 'admin_users': []}
[INFO][2024-07-18 11:32:05][godcmd.py:194] - [Godcmd] 因未设置口令,本次的临时口令为1945。
[INFO][2024-07-18 11:32:05][godcmd.py:210] - [Godcmd] inited
[DEBUG][2024-07-18 11:32:05][keyword.py:34] - [keyword]加载配置文件/root/chatgpt-on-wechat/plugins/keyword/config.json
[INFO][2024-07-18 11:32:05][keyword.py:40] - [keyword] {}
[INFO][2024-07-18 11:32:05][keyword.py:42] - [keyword] inited.
[DEBUG][2024-07-18 11:32:05][plugin.py:21] - loading plugin config, plugin_config_path=./plugins/tool/config.json, exist=False
[DEBUG][2024-07-18 11:32:05][plugin.py:28] - loading plugin config, plugin_name=tool, conf=None
[INFO][2024-07-18 11:32:06][tool.py:28] - [tool] inited
[DEBUG][2024-07-18 11:32:06][role.py:62] - [Role] no role found for tag comments 
[INFO][2024-07-18 11:32:06][role.py:69] - [Role] inited
[INFO][2024-07-18 11:32:06][dungeon.py:56] - [Dungeon] inited
[DEBUG][2024-07-18 11:32:06][plugin.py:21] - loading plugin config, plugin_config_path=./plugins/hello/config.json, exist=False
[DEBUG][2024-07-18 11:32:06][plugin.py:28] - loading plugin config, plugin_name=Hello, conf=None
[DEBUG][2024-07-18 11:32:06][hello.py:119] - No Hello plugin config.json, use plugins/hello/config.json.template
[INFO][2024-07-18 11:32:06][hello.py:38] - [Hello] inited
[INFO][2024-07-18 11:32:06][finish.py:23] - [Finish] inited
http://0.0.0.0:8887/
[INFO][2024-07-18 11:32:51][wechatcomapp_channel.py:133] - [wechatcom] receive params: <Storage {'echostr': 'kok7NY0fWYeUj65edkU9eVlFA7GKKiIlZ5ZadGrUyHWSx7LHU1E6tdv7P0ZLy1nPgep8YvMPz6R6WN1xFuWC4g==', 'msg_signature': '04ba8d435feb641eeb41ea9db2f8583a31dadae0', 'timestamp': '1721273570', 'nonce': '1720812724'}>
106.55.201.217:49066 - - [18/Jul/2024 11:32:51] "HTTP/1.1 GET /wxcomapp" - 200 OK
[INFO][2024-07-18 11:32:52][wechatcomapp_channel.py:133] - [wechatcom] receive params: <Storage {'echostr': 'kok7NY0fWYeUj65edkU9eVlFA7GKKiIlZ5ZadGrUyHWSx7LHU1E6tdv7P0ZLy1nPgep8YvMPz6R6WN1xFuWC4g==', 'msg_signature': '04ba8d435feb641eeb41ea9db2f8583a31dadae0', 'timestamp': '1721273570', 'nonce': '1720812724'}>
112.53.2.93:20510 - - [18/Jul/2024 11:32:52] "HTTP/1.1 GET /wxcomapp" - 200 OK
6vision commented 1 month ago

1、浏览器直接访问这个url提示什么? 2、接入微信等其他渠道是否正常?

ContrapunctusXIV commented 1 month ago
  1. 直接访问会报502错误,以下是服务器报错信息

`[INFO][2024-07-18 18:15:10][wechatcomapp_channel.py:133] - [wechatcom] receive params: <Storage {}> Traceback (most recent call last): File "/root/cow-bot/chatbot-venv/lib/python3.8/site-packages/web/utils.py", line 104, in getattr return self[key] KeyError: 'msg_signature'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/cow-bot/chatbot-venv/lib/python3.8/site-packages/web/application.py", line 280, in process return self.handle() File "/root/cow-bot/chatbot-venv/lib/python3.8/site-packages/web/application.py", line 271, in handle return self._delegate(fn, self.fvars, args) File "/root/cow-bot/chatbot-venv/lib/python3.8/site-packages/web/application.py", line 517, in _delegate return handle_class(cls) File "/root/cow-bot/chatbot-venv/lib/python3.8/site-packages/web/application.py", line 495, in handle_class return tocall(*args) File "/root/cow-bot/chatgpt-on-wechat/channel/wechatcom/wechatcomapp_channel.py", line 135, in GET signature = params.msg_signature File "/root/cow-bot/chatbot-venv/lib/python3.8/site-packages/web/utils.py", line 106, in getattr raise AttributeError(k) AttributeError: 'msg_signature'

116.25.243.146:57658 - - [18/Jul/2024 18:15:10] "HTTP/1.1 GET /wxcomapp" - 500 Internal Server Error`

  1. 接入个人微信渠道可以正常使用
6vision commented 1 month ago

应该是企微相关参数配置的问题,可以检查一下或者重新配置

ContrapunctusXIV commented 1 month ago

我尝试了更换应用、更换企业、也把python版本降为了3.8,但都是同样的问题。根据企业微信文档,需要1秒内把请求内容返回回去,是不是这部分代码有调整?

ContrapunctusXIV commented 1 month ago

找到解决方法了,可能是双网卡导致返回消息的ip与接收的不一致,禁用其中一个网卡后解决了。