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

SendMessage hangs indefinitely on some sendMessageText field values #158

Open
tim2CF opened this issue Dec 27, 2023 · 1 comment
Open

SendMessage hangs indefinitely on some sendMessageText field values #158

tim2CF opened this issue Dec 27, 2023 · 1 comment

Comments

@tim2CF
Copy link

tim2CF commented Dec 27, 2023

Example. No success or error returned, no exception is thrown, no logs produced, "SENT!" line is never reached. Basically everything just hangs on Tele.sendMessage line. Telegram Bot API might not support nested HTML tags, but in this case I expect some sort of exception. Current behaviour might be caused by the way how exceptions are handled inside servant client, but I don't know how to debug or fix it properly.

import qualified Telegram.Bot.API as Tele
import qualified Telegram.Bot.Simple as Tele
import qualified Telegram.Bot.Simple.Debug as Tele

sendTeleMsg :: Tele.BotM ()
sendTeleMsg = do
  putStrLn ("SENDING" :: Text)
  response <-
    Tele.liftClientM
      $ Tele.sendMessage
        Tele.SendMessageRequest
          { Tele.sendMessageChatId = Tele.SomeChatUsername chat,
            Tele.sendMessageMessageThreadId = Nothing,
            Tele.sendMessageText =
              "<a href=\"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Haskell-Logo.svg/2560px-Haskell-Logo.svg.png\"><span>[image]</span></a>",
            Tele.sendMessageParseMode = Just Tele.HTML,
            Tele.sendMessageEntities = Nothing,
            Tele.sendMessageDisableWebPagePreview = Just True,
            Tele.sendMessageDisableNotification = Just True,
            Tele.sendMessageProtectContent = Nothing,
            Tele.sendMessageReplyToMessageId = Nothing,
            Tele.sendMessageAllowSendingWithoutReply = Nothing,
            Tele.sendMessageReplyMarkup = Nothing
          }
  putStrLn ("SENT!" :: Text)
@tim2CF
Copy link
Author

tim2CF commented Dec 30, 2023

I was manage to reach some limited success with decreasing Manager timeout. For example this env setup works ok, and gives timeout exception in case Telegram API does not reply (for whatever reason):

  man <-
    Http.newManager
      $ Http.tlsManagerSettings
        { Http.managerResponseTimeout = Http.responseTimeoutMicro 20_000_000
        }
  pusher <-
    Tele.startBotAsync teleBot
      . Servant.mkClientEnv man
      . Tele.botBaseUrl
      . Tele.Token
      $ token

However, if I increase timeout just a bit more to ~ 25.9 seconds, it behaves badly again, and never throw timeout exception. Might be this strange behavioural shift related to this line somehow? Any ideas for a good fix?

(Telegram.GetUpdatesRequest offset Nothing (Just 25) Nothing))

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

1 participant