rockneurotiko/ex_gram

Continuous timeout error when polling

Closed this issue · 8 comments

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.

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

@rockneurotiko I think it's using Finch

Can you try the branch of this PR? #137

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

@rockneurotiko nope, still failing. Same error.

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

@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]

it worked! thanks @rockneurotiko

I released version 0.50.1 with this fix!