sakarie9 / TG-EFB-QQ-Docker

QQ和Telegram的双向消息转发
GNU Affero General Public License v3.0
193 stars 17 forks source link

部署成功后,无法发送图片 #34

Open duoyulee opened 1 year ago

duoyulee commented 1 year ago

tg报错: Message is not sent. CoolQDisconnectedException('Unable to connect to CoolQ Client!Error Message:\nHTTP request failed')

gocq log [2022-11-19 18:35:22] [WARNING]: 警告: 私聊 *** 图片上传失败: upload failed: connect error: dial tcp 180.109.192.140:443: i/o timeout [2022-11-19 18:35:22] [WARNING]: 好友消息发送失败: 消息为空

efb log:

2022-11-19 10:35:07,734 [ERROR]: efb_telegram_master.master_message (master_message.process_telegram_message; master_message.py:422)
    Message is not sent. (update: {'message': {'group_chat_created': False, 'chat': {'title': '🐧👤 小小', 'type': 'group', 'all_members_are_administrators': True, 'id': -573349043}, 'supergroup_chat_created': False, 'message_id': 2981, 'caption_entities': [], 'channel_chat_created': False, 'photo': [{'file_unique_id': 'AQADBrMxGzACyVd4', 'height': 71, 'file_size': 1454, 'width': 90, 'file_id': 'AgACAgUAAxkBAAILpWN4sVTjuusUgMaNrPlw6kIuH0x9AAIGszEbMALJV-EL6vl6JzbNAQADAgADcwADKwQ'}, {'file_unique_id': 'AQADBrMxGzACyVdy', 'height': 251, 'file_size': 23807, 'width': 320, 'file_id': 'AgACAgUAAxkBAAILpWN4sVTjuusUgMaNrPlw6kIuH0x9AAIGszEbMALJV-EL6vl6JzbNAQADAgADbQADKwQ'}, {'file_unique_id': 'AQADBrMxGzACyVd9', 'height': 628, 'file_size': 101254, 'width': 800, 'file_id': 'AgACAgUAAxkBAAILpWN4sVTjuusUgMaNrPlw6kIuH0x9AAIGszEbMALJV-EL6vl6JzbNAQADAgADeAADKwQ'}, {'file_unique_id': 'AQADBrMxGzACyVd-', 'height': 1005, 'file_size': 154450, 'width': 1280, 'file_id': 'AgACAgUAAxkBAAILpWN4sVTjuusUgMaNrPlw6kIuH0x9AAIGszEbMALJV-EL6vl6JzbNAQADAgADeQADKwQ'}], 'entities': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'new_chat_members': [], 'date': 1668854100, 'from': {'last_name': 'yu', 'username': 'chengzilee', 'language_code': 'zh-hans', 'is_bot': False, 'first_name': 'Duo', 'id': 2139115741}}, 'update_id': 109876112}, exception: Unable to connect to CoolQ Client!Error Message:
HTTP request failed)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 33, in read
    return await self._stream.receive(max_bytes=max_bytes)
  File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 1265, in receive
    await self._protocol.read_event.wait()
  File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
    yield
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 35, in read
    return b""
  File "/usr/local/lib/python3.9/site-packages/anyio/_core/_tasks.py", line 118, in __exit__
    raise TimeoutError
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
    return await self._connection.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 105, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 84, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 148, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 177, in _receive_event
    data = await self._network_stream.read(
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 35, in read
    return b""
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc)
httpcore.ReadTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiocqhttp/api_impl.py", line 66, in call_action
    resp = await client.post(self._api_root + action,
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1842, in post
    return await self.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1527, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1614, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1642, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1679, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1716, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/efb_qq_plugin_go_cqhttp/GoCQHttp.py", line 809, in _coolq_api_wrapper
    res = await self.coolq_bot.call_action(func_name, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/aiocqhttp/__init__.py", line 238, in call_action
    return await self._api.call_action(action=action, **params)
  File "/usr/local/lib/python3.9/site-packages/aiocqhttp/api_impl.py", line 185, in call_action
    result = await self._http_api.call_action(action, **params)
  File "/usr/local/lib/python3.9/site-packages/aiocqhttp/api_impl.py", line 75, in call_action
    raise NetworkError('HTTP request failed')
aiocqhttp.exceptions.NetworkError: HTTP request failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/efb_telegram_master/master_message.py", line 405, in process_telegram_message
    slave_msg = coordinator.send_message(m)
  File "/usr/local/lib/python3.9/site-packages/ehforwarderbot/coordinator.py", line 113, in send_message
    return slaves[msg.deliver_to.channel_id].send_message(msg)
  File "/usr/local/lib/python3.9/site-packages/efb_qq_slave/__init__.py", line 80, in send_message
    return self.QQClient.send_message(msg)
  File "/usr/local/lib/python3.9/site-packages/efb_qq_plugin_go_cqhttp/GoCQHttp.py", line 701, in send_message
    msg.uid = asyncio.run(self.coolq_send_message(chat_type[0], chat_type[1], text))
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/site-packages/efb_qq_plugin_go_cqhttp/GoCQHttp.py", line 804, in coolq_send_message
    res = await self.coolq_api_query("send_msg", message_type=msg_type, **{keyword + "_id": uid}, message=message)
  File "/usr/local/lib/python3.9/site-packages/efb_qq_plugin_go_cqhttp/GoCQHttp.py", line 838, in coolq_api_query
    return await self._coolq_api_wrapper(func_name, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/efb_qq_plugin_go_cqhttp/GoCQHttp.py", line 811, in _coolq_api_wrapper
    raise CoolQDisconnectedException(("Unable to connect to CoolQ Client!" "Error Message:\n{}").format(str(e)))
efb_qq_plugin_go_cqhttp.Exceptions.CoolQDisconnectedException: Unable to connect to CoolQ Client!Error Message:
HTTP request failed

配置文件

account: # 账号相关
  encrypt: false  # 是否开启密码加密
  status: 0      # 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态
  relogin: # 重连设置
    delay: 3   # 首次重连延迟, 单位秒
    interval: 3   # 重连间隔
    max-times: 0  # 最大重连次数, 0为无限制

  use-sso-address: true
  # 是否允许发送临时会话消息
  allow-temp-session: false

heartbeat:
  # 心跳频率, 单位秒
  # -1 为关闭心跳
  interval: 5

message:
  # 上报数据类型
  # 可选: string,array
  post-format: array
  # 是否忽略无效的CQ码, 如果为假将原样发送
  ignore-invalid-cqcode: false
  # 是否强制分片发送消息
  # 分片发送将会带来更快的速度
  # 但是兼容性会有些问题
  force-fragment: false
  # 是否将url分片发送
  fix-url: false
  # 下载图片等请求网络代理
  proxy-rewrite: ''
  # 是否上报自身消息
  report-self-message: false
  # 移除服务端的Reply附带的At
  remove-reply-at: true
  # 为Reply附加更多信息
  extra-reply-data: true
  # 跳过 Mime 扫描, 忽略错误数据
  skip-mime-scan: false

output:
  log-level: warn
  log-aging: 15
  log-force-new: true
  log-colorful: true
  debug: false # 开启调试模式

# 默认中间件锚点
default-middlewares: &default
  access-token: ''
  filter: ''
  rate-limit:
    enabled: false # 是否启用限速
    frequency: 1  # 令牌回复频率, 单位秒
    bucket: 1     # 令牌桶大小

database: # 数据库相关设置
  leveldb:
    # 是否启用内置leveldb数据库
    # 启用将会增加10-20MB的内存占用和一定的磁盘空间
    # 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能
    enable: true

  # 媒体文件缓存, 删除此项则使用缓存文件(旧版行为)
  cache:
    image: data/image.db
    video: data/video.db

# 连接服务列表
servers:
  # 添加方式,同一连接方式可添加多个,具体配置说明请查看文档
  #- http: # http 通信
  #- ws:   # 正向 Websocket
  #- ws-reverse: # 反向 Websocket
  #- pprof: #性能分析服务器

  - http: # HTTP 通信设置
      address: 127.0.0.1:5700 # HTTP监听地址
      timeout: 5      # 反向 HTTP 超时时间, 单位秒,<5 时将被忽略
      long-polling:   # 长轮询拓展
        enabled: false       # 是否开启
        max-queue-size: 2000 # 消息队列大小,0 表示不限制队列大小,谨慎使用
      middlewares:
        <<: *default # 引用默认中间件
      post:           # 反向HTTP POST地址列表
      #- url: ''                # 地址
      #  secret: ''             # 密钥
      #  max-retries: 3         # 最大重试,0 时禁用
      #  retries-interval: 1500 # 重试时间,单位毫秒,0 时立即
      #- url: http://127.0.0.1:5701/ # 地址
      #  secret: ''                  # 密钥
      #  max-retries: 10             # 最大重试,0 时禁用
      #  retries-interval: 1000      # 重试时间,单位毫秒,0 时立即
      - url: http://127.0.0.1:8000/ # 地址
        secret: ''          # 密钥

环境信息 圣何塞 vps ubuntu-20

问题: 可以正常收发文字信息和qq发来的图片,但无法通过tg发送图片及视频

google以及查看相关问题的issue后 配置文件中多次修改地址docker-compose up && docker-compose down 仍无法解决,相关端口都已放行

sakarie9 commented 1 year ago

可能是 vps 到 qq 服务器之间的连接出现了问题?

试一试 自定义服务器IP

duoyulee commented 1 year ago

自定义ip后问题依旧 好像是因为api端口的问题,使用ufw开放5700和8000的端口后显示容器在进行监听。但端口无数据无数据响应


lsof -i:8000
go-cqhttp 55555 root   23u  IPv4 661250      0t0  TCP localhost:47114->localhost:8000 (ESTABLISHED)
go-cqhttp 55555 root   24u  IPv4 661251      0t0  TCP localhost:47128->localhost:8000 (ESTABLISHED)
ehforward 55675 root   12u  IPv4 661731      0t0  TCP localhost:8000->localhost:47114 (ESTABLISHED)
ehforward 55675 root   14u  IPv4 661729      0t0  TCP localhost:8000 (LISTEN)
ehforward 55675 root   16u  IPv4 661745      0t0  TCP localhost:8000->localhost:47128 (ESTABLISHED)

lsof -i:5700 go-cqhttp 55555 root 19u IPv4 661186 0t0 TCP localhost:5700 (LISTEN)

curl 127.0.0.1:5700 {"data":null,"msg":"API_NOT_FOUND","retcode":404,"status":"failed","wording":"API不存在"}



实际使用过程中也只有图片和视频无法通过tg发送,其他功能正常。
duoyulee commented 1 year ago

可能是 vps 到 qq 服务器之间的连接出现了问题?

试一试 自定义服务器IP

而且好像是间歇性发作( 大部分时间无法发送图片,间或会有能发出去一张(大概是30:1的样子?),发送成功的时候能看5700的连接状态如下

lsof 5700
go-cqhttp 55555 root   16u  IPv4 662471      0t0  TCP localhost:5700->localhost:44482 (ESTABLISHED)
go-cqhttp 55555 root   19u  IPv4 661186      0t0  TCP localhost:5700 (LISTEN)
ehforward 55675 root   18u  IPv4 663251      0t0  TCP localhost:44482->localhost:5700 (ESTABLISHED)

这种情况是因为国外ip导致的不稳定吗还是需要在配置文件做修改?