无法转发(我这个菜鸡实在搞不懂……(暴风哭泣
Opened this issue · 34 comments
症状描述
两边都无法转发,酷q机器人正常,debug日志可以看到tg消息,但是提示Connection aborted. ?
-使用docker构建 https://github.com/Z4HD/coolq-telegram-bot-docker
-使用的稳定版
-酷q日志中显示已启用http-api
python3 daemon.py run 的执行输出
2017-12-25 11:23:31,526 [INFO] CTBMain - daemon(daemon.py) : Now running in debug mode...
2017-12-25 11:23:31,528 [DEBUG] telegram.ext.dispatcher - dispatcher(dispatcher.py) : Setting singleton dispatcher as <telegram.ext.dispatcher.Dispatcher object at 0x7f8749c8bcf8>
2017-12-25 11:23:31,529 [DEBUG] telegram.ext.updater - updater(updater.py) : dispatcher - started
2017-12-25 11:23:31,530 [DEBUG] telegram.ext.updater - updater(updater.py) : updater - started
2017-12-25 11:23:31,530 [DEBUG] telegram.ext.updater - updater(updater.py) : Updater thread started
2017-12-25 11:23:31,531 [DEBUG] telegram.bot - bot(bot.py) : Entering: set_webhook
2017-12-25 11:23:31,532 [DEBUG] telegram.vendor.ptb_urllib3.urllib3.connectionpool - connectionpool(connectionpool.py) : Starting new HTTPS connection (1): api.telegram.org
Bottle v0.12.13 server starting up (using WSGIRefServer())...
2017-12-25 11:23:31,533 [DEBUG] CTBPlugin.plugins.qq_namelist - qq_namelist(qq_namelist.py) : plugins.qq_namelist loading
2017-12-25 11:23:31,534 [DEBUG] CTBMain.command - command(command.py) : Registering new command: update namelist(update_namelist)
2017-12-25 11:23:31,534 [DEBUG] CTBMain.command - command(command.py) : update namelist(update_namelist) added to global_vars
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
2017-12-25 11:23:31,549 [DEBUG] telegram.ext.dispatcher - dispatcher(dispatcher.py) : Dispatcher started
2017-12-25 11:23:32,245 [DEBUG] telegram.vendor.ptb_urllib3.urllib3.connectionpool - connectionpool(connectionpool.py) : https://api.telegram.org:443 "POST /bot495582135:AAES4-9APp7Mdo3KC5MYXrdJ2GzW8mHpxA8/setWebhook HTTP/1.1" 200 68
2017-12-25 11:23:32,245 [DEBUG] telegram.bot - bot(bot.py) : True
2017-12-25 11:23:32,246 [DEBUG] telegram.bot - bot(bot.py) : Exiting: set_webhook
2017-12-25 11:23:32,246 [DEBUG] telegram.bot - bot(bot.py) : Entering: get_updates
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.6/dist-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
配置文件
bot_constant.json
{
"DEBUG_MODE": true,
"BAIDU_API": "",
"API_ROOT": "http://127.0.01:5700/",
"ACCESS_TOKEN": "very",
"SECRET": "long",
"HOST": "127.0.0.1",
"PORT": 8080,
"TOKEN": "**************",
"QQ_BOT_ID": "*********",
"FORWARD_LIST": [
{
"QQ": *********群号,
"TG": *********,
"DRIVE_MODE": false,
"IMAGE_LINK": true
}
],
"SERVER_PIC_URL": "http://expample.com/image/",
"CQ_ROOT": "/home/user/coolq/",
"JQ_MODE": false
}
app/io.github.richardchien.coolqhttpapi/config.cfg
[general]
host=0.0.0.0
port=5700
use_http=yes
ws_host=0.0.0.0
ws_port=5700
use_ws=no
post_url=http://自己的ip:8080/
access_token=very
secret=long
post_message_format=array
serve_data_files=no
update_source=https://raw.githubusercontent.com/richardchien/coolq-http-api-release/master/
update_channel=stable
auto_check_update=no
auto_perform_update=no
thread_pool_size=4
server_thread_pool_size=1
请问你在 tg群组使用 !!id 是否有反应
如果没反应请检查telegram 服务器的连接性
请不要将本bot置于国内ipv4环境运行
无反应
bot放在国外vps上
orz
感觉你的服务器连不上 telegram,你需要检查下你的网络
ping api.telegram.org 试试
28 packets transmitted, 28 received, 0% packet lo
ss, time 27038ms
可以ping通,请问会不会是我哪里配置错了...(不过我仔细检查过token这些东西我还是没填错的orz
效果是对端关闭了连接,你检查下 tg 的 token 写的对不对吧
???真的没有填错……
有一个问题是,你的 config 里的127.0.0.1写成了127.0.01
@jqqqqqqqqqq 天呐,我也没看出来!
修改过了重启服务依然报错……(我的天太尴尬了我的眼癌手癌……orz
2017-12-25 12:53:27,826 [DEBUG] telegram.bot - bot(bot.py) : True
2017-12-25 12:53:27,826 [DEBUG] telegram.bot - bot(bot.py) : Exiting: set_webhook
2017-12-25 12:53:27,827 [DEBUG] telegram.bot - bot(bot.py) : Entering: get_updates
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.6/dist-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "daemon.py", line 118, in <module>
main()
File "daemon.py", line 106, in main
daemon.run()
File "daemon.py", line 76, in run
import plugins # load all plugins
File "/home/user/coolq-telegram-bot/plugins/__init__.py", line 1, in <module>
import plugins.qq_namelist
File "/home/user/coolq-telegram-bot/plugins/qq_namelist.py", line 42, in <module>
reload_all_qq_namelist()
File "/home/user/coolq-telegram-bot/plugins/qq_namelist.py", line 17, in reload_all_qq_namelist
global_vars.group_members[i] = global_vars.qq_bot.get_group_member_list(group_id=FORWARD_LIST[i]['QQ'])
File "/home/user/coolq-telegram-bot/cqhttp/__init__.py", line 34, in __call__
headers=headers
File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
@STun6 通常建议HTTP APIpost_url
的值与Bot配置文件中HOST
PORT
的值对应以正确接收API的事件上报。
建议您在HTTP API的配置文件中进行如下更改:
post_url=http://127.0.0.1:8080/
@Z4HD 按照建议修改后依然如上报错……
(俺实在是知识浅薄……
(打扰各位大佬过圣诞节了 (´;ω;`)
(突然意识到
@STun6 你的日志没有脱敏……
@STun6 或许 是 bot 在群组里的权限?(不确定
@xyf1219 已将bot加入管理员……?
日志里(一直)可以显示tg群组里发的消息,但是就是无法转发……(´;ω;`)
File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
@STun6 你的这个问题就是 Bot 无法连接 Coolq 服务端,要么是API地址写的不对,要么是服务端启动有问题。你可以试试重启下 Coolq 服务端
@STun6 请问你在QQ上向Bot发送类似!!sc
等命令,Bot是否有响应?Coolq上是否出现相关日志?
@Z4HD 那个命令改成了 !!cmd
@jqqqqqqqqqq 重启依然没用orz
@Z4HD bot无反应,日志中有记录(无论是qq那边还是tg……发送以下指令都没有反应)
@Z4HD 不是,master 已经 merge 了
tg 那边发 !!cmd 还是没反应么,能看到 log 没看到exception?
这比较奇怪,按理说 tg 至少得是正常的
@Z4HD
是的tg没有回应……
tg机器人加入了管理员,是否还需要别的设置?
log如下
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
**requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))**
2017-12-28 04:15:22,952 [DEBUG] telegram.vendor.ptb_urllib3.urllib3.connectionpool - connectionpool(connectionpool.py) : https://api.telegram.org:443 "POST /bot495582135:AAES4-9APp7M**********2GzW8mHpxA8/getUpdates HTTP/1.1" 200 326
2017-12-28 04:15:22,953 [DEBUG] telegram.bot - bot(bot.py) : Getting updates: [136050358]
2017-12-28 04:15:22,954 [DEBUG] telegram.bot - bot(bot.py) : [<telegram.update.Update object at 0x7f576c34fa58>]
2017-12-28 04:15:22,954 [DEBUG] telegram.bot - bot(bot.py) : Exiting: get_updates
2017-12-28 04:15:22,954 [DEBUG] telegram.ext.dispatcher - dispatcher(dispatcher.py) : Processing Update: {'update_id': ********, 'message': {'message_id': 160, 'date': ******, 'chat': {'id': *******, 'type': 'group', 'title': '******', 'all_members_are_administrators': False}, 'text': '!!cmd','entities': [], 'caption_entities': [], 'photo': [], 'new_chat_members': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'from': {'id': *********, 'first_name': '*', 'is_bot': False, 'last_name': '*', 'username': '**********', 'language_code': 'en'}, 'new_chat_member': None}}
我测试了一下,如果 token 写错了是 unauthorized,所以你应该不是这个问题
那么你这个 connection aborted 是其他原因导致的。
感觉就是网络问题,你试试ssh 直接执行
curl -i -X GET https://api.telegram.org/bot<apikey>/getMe
把 <apikey> 换成你的 apikey 看看能不能返回正常结果
如果是直接 connection aborted 你就可以考虑换机房了
@jqqqqqqqqqq
网络完全okk……
HTTP/1.1 200 OK
Server: nginx/1.12.2
Date: Thu, 28 Dec 2017 04:33:56 GMT
Content-Type: application/json
Content-Length: 111
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Expose-Headers: Content-Length,Content-Type,Date,Server,Connection
Strict-Transport-Security: max-age=31536000; includeSubdomains
那就不是 telegram 的问题,你在 telegram 发送 !!help 或者 !!cmd 应当是有反应的。
看起来是 coolq 服务端插件连不上,检查 coolq 插件管理里边插件是否启用,coolq log 中有没有插件的启动日志
bot 是否在容器内运行
在容器中运行bot ,使用这个构建 https://github.com/Z4HD/coolq-telegram-bot-docker
确认插件已使用,coolq log里有日志记录
不过我发现插件配置文件中填写的5700端口在本地并未打开……会不会是这个问题呢?
(不会用docker ……orz
端口没打开是个奇怪的问题,插件已启用但是没监听端口很奇怪。。要不你试试重新构造一个 docker?
正好 httpapi插件和我的 bot 都更新了
@jqqqqqqqqqq
诶重建后(这次手动打开了5700端口)没有Connection aborted的报错了……
但是还是不能转发,
发送!!cmd命令 tg/qq均无反应,在log和coolq里有相关消息记录,确认开启cq-http-api
2017-12-28 08:02:23,656 [INFO] ctbMain.jsonConstantSupport - daemon(daemon.py) : Now running in debug mode...
2017-12-28 08:02:23,656 [INFO] ctbMain.jsonConstantSupport - daemon(daemon.py) : Now running in debug mode...
2017-12-28 08:02:23,658 [DEBUG] telegram.ext.dispatcher - dispatcher(dispatcher.py) : Setting singleton dispatcher as <telegram.ext.dispatcher.Dispatcher object at 0x7fc76dbbde80>
2017-12-28 08:02:23,659 [DEBUG] JobQueue - jobqueue(jobqueue.py) : JobQueue thread started
2017-12-28 08:02:23,660 [DEBUG] telegram.ext.updater - updater(updater.py) : dispatcher - started
2017-12-28 08:02:23,660 [DEBUG] telegram.ext.updater - updater(updater.py) : updater - started
2017-12-28 08:02:23,660 [DEBUG] telegram.ext.updater - updater(updater.py) : Updater thread started
2017-12-28 08:02:23,661 [DEBUG] telegram.bot - bot(bot.py) : Entering: set_webhook
2017-12-28 08:02:23,661 [DEBUG] telegram.vendor.ptb_urllib3.urllib3.connectionpool - connectionpool(connectionpool.py) : Starting new HTTPS connection (1): api.telegram.org
Bottle v0.12.13 server starting up (using WSGIRefServer())...
2017-12-28 08:02:23,663 [DEBUG] CTBPlugin.plugins.qq_namelist - qq_namelist(qq_namelist.py) : plugins.qq_namelist loading
2017-12-28 08:02:23,663 [DEBUG] CTBPlugin.plugins.qq_namelist - qq_namelist(qq_namelist.py) : plugins.qq_namelist loading
2017-12-28 08:02:23,664 [DEBUG] CTBMain.command - command(command.py) : Registering new command: update namelist(update_namelist)
2017-12-28 08:02:23,664 [DEBUG] CTBMain.command - command(command.py) : update namelist(update_namelist) added to global_vars
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
2017-12-28 08:02:23,671 [DEBUG] telegram.ext.dispatcher - dispatcher(dispatcher.py) : Dispatcher started
2017-12-28 08:02:24,372 [DEBUG] telegram.vendor.ptb_urllib3.urllib3.connectionpool - connectionpool(connectionpool.py) : https://api.telegram.org:443 "POST /bot495582135:AAES4-9APp7Mdo3KC5*****xA8/setWebhook HTTP/1.1" 200 68
2017-12-28 08:02:24,373 [DEBUG] telegram.bot - bot(bot.py) : True
2017-12-28 08:02:24,374 [DEBUG] telegram.bot - bot(bot.py) : Exiting: set_webhook
2017-12-28 08:02:24,374 [DEBUG] telegram.bot - bot(bot.py) : Entering: get_updates
试试发 !!id
@jqqqqqqqqqq 没有反应
而且我又重建后又出现了Connection aborted……
那我也不知道怎么办了,就算缺少 Coolq 那一半,直接运行 bot,telegram 这边的命令也是可以用的。只是转发会不能工作。照你描述 telegram 这一半工作也不正常,我想应该不是我的问题了
可以试试直接 run,然后看看 log
新加了一些有关 coolq http api 连接检查的机制
Closed due to timed out