Dankoy / jforwarder

Telegram bot for coub.com communities, tags and channels subscriptions.
https://t.me/coub_forwarder_bot
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Async bot flow doesn't handle exceptions when sending messages #126

Closed Dankoy closed 2 months ago

Dankoy commented 2 months ago

Describe the bug Spring integration flow is async by default. The controller that uses MessagingGateway just sends message for processing and immediately returns 200 to kafka-consumer. Which leads to sending ACK message to kafka and updating sent coubs registry. But when telegram network is not working then message is never sent, but application thinks it has been sent.

To Reproduce Send message when telegram has problems with network.
o.t.t.u.DefaultBotSession : Network unreachable

Expected behavior When kafka consumer sends message it waits for 200 response. For other codes consumer never acknowledges message with ACK. So it will try to resend it later.
The controller in telegram bot should wait for message to be processed and if everything is okay, then send 200 OK. If not then response with some error message.

Documentation

Desktop (please complete the following information):

Additional context

    2024-08-21 14:06:23.642 
2024-08-21T14:06:23.642+03:00 ERROR [telegram-bot,,] 1 --- [telegram-bot] [coub_forwarder_bot Telegram Connection] [                                                 ] o.t.t.u.DefaultBotSession                : Network unreachable

java.net.SocketException: Network unreachable
    at java.base/sun.nio.ch.Net.connect0(Native Method)
    at java.base/sun.nio.ch.Net.connect(Unknown Source)
    at java.base/sun.nio.ch.Net.connect(Unknown Source)
    at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
    at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
    at java.base/java.net.Socket.connect(Unknown Source)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.getUpdatesFromServer(DefaultBotSession.java:249)
    at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$ReaderThread.run(DefaultBotSession.java:188)