rockneurotiko / ex_gram

Telegram Bot API low level API and framework
183 stars 26 forks source link

Continuous timeout error when polling #136

Closed manuel-rubio closed 7 months ago

manuel-rubio commented 7 months ago

When the bot is running and it's idle, I can see this:

[error] GET https://api.telegram.org/botXXX/getUpdates -> error: "timeout" (15131.153 ms)
[debug] 
>>> REQUEST >>>
Query: timeout: 50
Query: offset: -1
Query: limit: 100

Content-Type: application/json

(no body)

<<< RESPONSE ERROR <<<
"timeout"

Looks like after 15 seconds, there was no information to be updated and it's performing a timeout but as an error while this kind of timeout should be only "info" instead of "error" because it's expected. The result is that I'm plenty of errors because most of the time the bot isn't doing anything every 15 seconds :-/

Maybe it's something at the Tesla adapter that I could configure but not sure at the moment. Any ideas? Thanks in advance.

rockneurotiko commented 7 months ago

This shouldn't be happening, in theory we are specifying a 60s receive timeout: https://github.com/rockneurotiko/ex_gram/blob/master/lib/ex_gram/adapter/tesla.ex#L122

What adapter are you using under Tesla? Maybe those options only works for hackney

manuel-rubio commented 7 months ago

@rockneurotiko I think it's using Finch

rockneurotiko commented 7 months ago

Can you try the branch of this PR? https://github.com/rockneurotiko/ex_gram/pull/137

I tried myself and it seems that with Finch or Hackney there are no longer timeout errors

manuel-rubio commented 7 months ago

@rockneurotiko nope, still failing. Same error.

manuel-rubio commented 7 months ago

In addition:

warning: passing non-atom as application env key is deprecated, got: {Tesla.Adapter.Finch, [name: ContaBot.Finch]}
  (elixir 1.15.7) lib/application.ex:720: Application.get_env/3
  (ex_gram 0.50.0) lib/ex_gram/adapter/tesla.ex:124: ExGram.Adapter.Tesla.adapter_opts/0
  (ex_gram 0.50.0) lib/ex_gram/adapter/tesla.ex:120: ExGram.Adapter.Tesla.opts/0
  (ex_gram 0.50.0) lib/ex_gram/adapter/tesla.ex:44: ExGram.Adapter.Tesla.do_request/3
  (ex_gram 0.50.0) lib/ex_gram/adapter/tesla.ex:32: ExGram.Adapter.Tesla.request/3
  (ex_gram 0.50.0) lib/ex_gram/macros/executer.ex:48: ExGram.Macros.Executer.execute_method/9
rockneurotiko commented 7 months ago

@manuel-rubio Oh, I forgot that you can pass the adapter to tesla as a tuple, that's why it's failing with timeout and you are getting that warning.

Can you try again? Now it should support module and {module, opts]

manuel-rubio commented 7 months ago

it worked! thanks @rockneurotiko

rockneurotiko commented 7 months ago

I released version 0.50.1 with this fix!