Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

回复消息报 httperror 错误,请问是否需要打开防火墙的某些端口? #4

Open
RekiDunois opened this issue Jul 11, 2021 · 6 comments

Comments

@RekiDunois
Copy link

接受消息没有问题,确认了 efb/profiles/default/blueset.telegram/config.yaml 中的 admins 与我的 id 相等。

回复任何消息和指令都无效,bot 没有任何反应。

使用 docker log efbv2 查看日志, 发现其反复报如下错误:

2021-07-11 05:00:19,672 [ERROR]: telegram.ext.updater (updater._network_loop_retry; updater.py:391)
    Error while getting Updates: urllib3 HTTPError ('Connection aborted.', OSError(0, 'Error'))
2021-07-11 05:00:19,673 [ERROR]: efb_telegram_master (__init__.error; __init__.py:477)
    Poor internet connection detected.
Number of network error occurred since last startup: 656
urllib3 HTTPError ('Connection aborted.', OSError(0, 'Error'))
Update: None

能将消息转发到 tg bot 说明可以访问到 tg 服务器,是否需要打开某些端口才能回复消息?

@RekiDunois
Copy link
Author

重新确认了一下 log,发现启动的时候 efb 会报如下错误:

2021-07-11 15:56:46,607 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:129)
     Initializing slave milkice.qq...
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
    return await fut
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.144.2', 8080)

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/mirai_core/network.py", line 98, in post
    response = await self.session.post(self.base_url + url, headers=headers, json=data)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host mirai:8080 ssl:default [Connect call failed ('192.168.144.2', 8080)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/efb_qq_slave/ClientMgr.py", line 27, in __init__
    self.client = cls(name, config, channel)
  File "/usr/local/lib/python3.8/site-packages/efb_qq_plugin_mirai/mirai.py", line 65, in __init__
    self.loop.run_until_complete(self.bot.handshake())
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/site-packages/mirai_core/bot.py", line 58, in handshake
    await self.auth()
  File "/usr/local/lib/python3.8/site-packages/mirai_core/bot.py", line 65, in auth
    result = await self.session.post('/auth', data={'authKey': self.auth_key})
  File "/usr/local/lib/python3.8/site-packages/mirai_core/network.py", line 100, in post
    raise NetworkException('Unable to reach Mirai console')
mirai_core.exceptions.NetworkException: Unable to reach Mirai console

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/ehforwarderbot", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/ehforwarderbot/__main__.py", line 335, in main
    init(conf)
  File "/usr/local/lib/python3.8/site-packages/ehforwarderbot/__main__.py", line 135, in init
    coordinator.add_channel(cls(instance_id=instance_id))
  File "/usr/local/lib/python3.8/site-packages/efb_qq_slave/__init__.py", line 44, in __init__
    self.init_client_manager()
  File "/usr/local/lib/python3.8/site-packages/efb_qq_slave/__init__.py", line 73, in init_client_manager
    self.QQClientMgr = ClientMgr(self.config['Client'], self.config, self)
  File "/usr/local/lib/python3.8/site-packages/efb_qq_slave/ClientMgr.py", line 30, in __init__
    raise Exception("Specified client not found!")
Exception: Specified client not found!

为什么这里会去连接 192.168.144.2 的地址呢?我局域网环境下并没有这一个地址。

另外,由于我是在 wsl 环境中部署,监听 8080 端口是有可能失败的,不知能否将端口改成其他来规避 wsl 的这个问题呢?

@sakarie9
Copy link
Owner

尝试根据 2c8bcba 修改docker-compose.ymlmilkice.qq/config.yaml

@RekiDunois
Copy link
Author

我试着修改了上述的两个文件,但是这次 docker-compose up 直接停止活动了,报了如下错误:

mirai    |  13:49:59 [ERROR] org.mozilla.javascript.WrappedException: Wrapped java.net.ConnectException (updater.js#51)
mirai    | 	at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1899)
mirai    | 	at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)
mirai    | 	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:226)
mirai    | 	at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1692)
mirai    | 	at script.check(updater.js:51)
mirai    | 	at script(updater.js:38)
mirai    | 	at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1013)
mirai    | 	at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
mirai    | 	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)
mirai    | 	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578)
mirai    | 	at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:107)
mirai    | 	at org.mozilla.javascript.ArrowFunction.call(ArrowFunction.java:43)
mirai    | 	at org.mozilla.javascript.InterfaceAdapter.invokeImpl(InterfaceAdapter.java:155)
mirai    | 	at org.mozilla.javascript.InterfaceAdapter.lambda$invoke$0(InterfaceAdapter.java:105)
mirai    | 	at org.mozilla.javascript.Context.call(Context.java:554)
mirai    | 	at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:522)
mirai    | 	at org.mozilla.javascript.InterfaceAdapter.invoke(InterfaceAdapter.java:105)
mirai    | 	at org.mozilla.javascript.jdk18.VMBridge_jdk18$1.invoke(VMBridge_jdk18.java:126)
mirai    | 	at com.sun.proxy.$Proxy4.run(Unknown Source)
mirai    | 	at org.itxtech.mcl.script.ScriptManager.phaseLoad(ScriptManager.java:93)
mirai    | 	at org.itxtech.mcl.Loader.start(Loader.java:153)
mirai    | 	at org.itxtech.mcl.Loader.main(Loader.java:66)
mirai    | Caused by: java.net.ConnectException
mirai    | 	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:561)
mirai    | 	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119)
mirai    | 	at org.itxtech.mcl.component.Repository.httpGet(Repository.java:128)
mirai    | 	at org.itxtech.mcl.component.Repository.fetchPackage(Repository.java:68)
mirai    | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
mirai    | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
mirai    | 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
mirai    | 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
mirai    | 	at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)
mirai    | 	... 18 more
mirai    | Caused by: java.net.ConnectException
mirai    | 	at java.net.http/jdk.internal.net.http.common.Utils.toConnectException(Utils.java:970)
mirai    | 	at java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:179)
mirai    | 	at java.net.http/jdk.internal.net.http.AsyncSSLConnection.connectAsync(AsyncSSLConnection.java:56)
mirai    | 	at java.net.http/jdk.internal.net.http.Http2Connection.createAsync(Http2Connection.java:370)
mirai    | 	at java.net.http/jdk.internal.net.http.Http2ClientImpl.getConnectionFor(Http2ClientImpl.java:127)
mirai    | 	at java.net.http/jdk.internal.net.http.ExchangeImpl.get(ExchangeImpl.java:89)
mirai    | 	at java.net.http/jdk.internal.net.http.Exchange.establishExchange(Exchange.java:306)
mirai    | 	at java.net.http/jdk.internal.net.http.Exchange.responseAsyncImpl0(Exchange.java:438)
mirai    | 	at java.net.http/jdk.internal.net.http.Exchange.responseAsyncImpl(Exchange.java:343)
mirai    | 	at java.net.http/jdk.internal.net.http.Exchange.responseAsync(Exchange.java:335)
mirai    | 	at java.net.http/jdk.internal.net.http.MultiExchange.responseAsyncImpl(MultiExchange.java:347)
mirai    | 	at java.net.http/jdk.internal.net.http.MultiExchange.lambda$responseAsyncImpl$7(MultiExchange.java:384)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:930)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture.uniHandleStage(CompletableFuture.java:946)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture.handle(CompletableFuture.java:2266)
mirai    | 	at java.net.http/jdk.internal.net.http.MultiExchange.responseAsyncImpl(MultiExchange.java:374)
mirai    | 	at java.net.http/jdk.internal.net.http.MultiExchange.lambda$responseAsync0$2(MultiExchange.java:293)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1072)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1705)
mirai    | 	at java.net.http/jdk.internal.net.http.HttpClientImpl$DelegatingExecutor.execute(HttpClientImpl.java:153)
mirai    | 	at java.base/java.util.concurrent.CompletableFuture.completeAsync(CompletableFuture.java:2591)
mirai    | 	at java.net.http/jdk.internal.net.http.MultiExchange.responseAsync(MultiExchange.java:246)
mirai    | 	at java.net.http/jdk.internal.net.http.HttpClientImpl.sendAsync(HttpClientImpl.java:632)
mirai    | 	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:540)
mirai    | 	... 26 more
mirai    | Caused by: java.nio.channels.UnresolvedAddressException
mirai    | 	at java.base/sun.nio.ch.Net.checkAddress(Net.java:130)
mirai    | 	at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:673)
mirai    | 	at java.net.http/jdk.internal.net.http.PlainHttpConnection.lambda$connectAsync$0(PlainHttpConnection.java:165)
mirai    | 	at java.base/java.security.AccessController.doPrivileged(Native Method)
mirai    | 	at java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:167)
mirai    | 	... 49 more
mirai    | 

然后就回到了 bash

@RekiDunois
Copy link
Author

换了一个环境之后使用 2c8bcba 进行部署,发现部署成功,可以正确启动 milkice.qq 从端

但是此时仍旧无法发送消息和 bot 指令。我发现日志中主要有两个异常:

第一个是

efb      |      Initializing middleware xzsk2.filter...
efb      | Traceback (most recent call last):
efb      |   File "/usr/local/bin/ehforwarderbot", line 8, in <module>
efb      |     sys.exit(main())
efb      |   File "/usr/local/lib/python3.8/site-packages/ehforwarderbot/__main__.py", line 335, in main
efb      |     init(conf)
efb      |   File "/usr/local/lib/python3.8/site-packages/ehforwarderbot/__main__.py", line 163, in init
efb      |     coordinator.add_middleware(cls(instance_id=instance_id))
efb      |   File "/usr/local/lib/python3.8/site-packages/efb_filter_middleware/__init__.py", line 42, in __init__
efb      |     raise EFBException("Filter middleware is not configured.")
efb      | ehforwarderbot.exceptions.EFBException: Filter middleware is not configured.

这个是中间件初始化错误。我在 efb/profiles/default/config.yaml 中屏蔽掉中间件 xzsk2.filter 之后,bot 就可以正常接收到指令并且作出反应了。

第二个是

mirai    | > 2021-07-12 21:01:49 W/console: Closing input service...
mirai    | 2021-07-12 21:16:41 V/Bot.xxxxxxxxx: Event: GroupMessagePreSendEvent(target=Group(xxxxxxxxx), message=可还行)
mirai    | 2021-07-12 21:16:44 V/Bot.xxxxxxxxx: Group(xxxxxxxxx) <- 可还行
mirai    | 2021-07-12 21:16:44 V/Bot.xxxxxxxxx: Event: GroupMessagePostSendEvent(target=Group(xxxxxxxxx), message=可还行, exception=null, receipt=net.mamoe.mirai.message.MessageReceipt@710ce0)

从日志可以看出,bot 能够收到我在 telegram 发送的消息,但是这条消息还是没有办法在 qq 中出现,不清楚到底是什么情况。看起来并没有报错才是。

@sakarie9
Copy link
Owner

原来是filter的问题...后续版本将默认关闭此中间件

发不出去群消息是qq的风控,在 mamoe/mirai#1209 有讨论

我之前是无法发送大于三个字符的群消息,接收正常;好友消息的收发正常。这种情况是触发了TX的风控,一般服务器上挂12小时-2天即可正常

@RekiDunois
Copy link
Author

看起来确实是风控,与好友私聊没有问题,但是群组中发不出去。就算是三个字符以下的也不行。看看挂久一点会不会正常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants