southbridgeio / tdlib-ruby

Ruby bindings and client for TDLib
MIT License
95 stars 48 forks source link

Lots of timeouts when sending messages #15

Closed oz closed 5 years ago

oz commented 6 years ago

Hi!

I've been playing with the lib recently, and enjoy it a lot. Thanks. :smile:

That being said, I have noticed that almost all my outgoing messages end-up with a TD::TimeoutError, even though they are delivered. Any idea what could cause this?

I'm running on Linux (Arch), ruby 2.5.1p57, and tdlib 1.3.0.


Here is some very basic code that I use to send e.g. text messages:

  class Chat
    # ... initialized earlier: @client = TD::Client.new

    def send_message(to, text)
      params = text_request to, text
      client
        .broadcast(params)
        .then { |result| log.info "Broadcast result: #{result}" }
        .rescue { |error| log.error "Error sending message: #{error}" }
        .value
    end

    def text_request(to, message)
      {
        '@type' => 'sendMessage',
        'chat_id' => to,
        'reply_to_message_id' => 0,
        'disable_notification' => false,
        'from_background' => false,
        'input_message_content' => {
          '@type' => 'inputMessageText',
          'text' => {
            '@type' => 'formattedText',
            'text' => text,
            'entities' => []
          }
        }
      }
    end
  end
vladislav-yashin commented 5 years ago

Please, check out v2.0.0

oz commented 5 years ago

I started to port client code to v2.0, and things have improved a lot. I'll close this one.

Thanks a lot! :+1: