Red-Teapot / MinecraftTelegramChatBridge

Spigot plugin that sends messages from Telegram to Minecraft and vice versa
MIT License
1 stars 1 forks source link

Handle Telegram network errors #4

Open MikeWent opened 10 months ago

MikeWent commented 10 months ago

Actual behavior

Plugin doesn't handle cases when Telegram server randomly disconnects, throws network errors, etc.

ERROR: [org.telegram.telegrambots.updatesreceivers.DefaultBotSession] Connect to api.telegram.org:443 [api.telegram.org/149.154.167.220] failed: Connect timed out
org.apache.http.conn.ConnectTimeoutException: Connect to api.telegram.org:443 [api.telegram.org/149.154.167.220] failed: Connect timed out
 at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.13.jar:4.5.13]
 at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.getUpdatesFromServer(DefaultBotSession.java:249) ~[tg-bridge-v0.0.1.jar:?]
 at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.run(DefaultBotSession.java:188) ~[tg-bridge-v0.0.1.jar:?]
Caused by: java.net.SocketTimeoutException: Connect timed out
 at sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546) ~[?:?]
 at sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592) ~[?:?]
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[?:?]
 at java.net.Socket.connect(Socket.java:751) ~[?:?]
 at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368) ~[httpclient-4.5.13.jar:4.5.13]
 at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ~[httpclient-4.5.13.jar:4.5.13]
 ... 10 more

Expected behavior

Plugin silently retries to connect, optionally logging Telegram errors.

Red-Teapot commented 10 months ago

Looks like it actually does reconnect, albeit with some log spam. I'll see if I can make it shut up