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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout configuration #11

Closed
john-griffin opened this issue May 12, 2017 · 11 comments
Closed

Timeout configuration #11

john-griffin opened this issue May 12, 2017 · 11 comments
Assignees

Comments

@john-griffin
Copy link
Contributor

We occasionally see timeouts when sending to the Postmark API. Is there a way to configure the max allowed timeout? Couldn't see an obvious way of doing it. Thanks! 馃槃

@pablo-co
Copy link
Owner

@john-griffin Right now there is no way to change the configuration of the request being made to Postmark. But it sounds like something that might be useful, I'll add it during the weekend. Will keep you posted.

@pablo-co pablo-co self-assigned this May 13, 2017
@john-griffin
Copy link
Contributor Author

@pablo-co thanks Pablo!

@pablo-co
Copy link
Owner

This feature was introduced in #12.

@pablo-co
Copy link
Owner

For quick reference, you can specify the timeout like this:

config :my_app, MyApp.Mailer,
      adapter: Bamboo.PostmarkAdapter,
      request_options: [recv_timeout: 10_000] # 10 seconds

@john-griffin
Copy link
Contributor Author

@pablo-co thanks, that looks perfect 馃槂

@joshuataylor
Copy link

Would this be the cause of Process #PID<0.23109.3> terminating: :closed?

Seeing this error sometimes, and the email doesn't send, stacktrace:

(bamboo_postmark) lib/bamboo/postmark_adapter.ex:51: Bamboo.PostmarkAdapter.deliver/2
(elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

@john-griffin
Copy link
Contributor Author

We didn't see that error, it was an explicit timeout error such as below:

[error] Task #PID<0.906.0> started from #PID<0.905.0> terminating 
** (Bamboo.PostmarkAdapter.ApiError) :timeout 
    lib/bamboo/postmark_adapter.ex:51: Bamboo.PostmarkAdapter.deliver/2 

@joshuataylor
Copy link

Seeing the following now:

12:55:23.130 [error] Task #PID<0.11200.0> started from #PID<0.11186.0> terminating
** (Bamboo.PostmarkAdapter.ApiError) :connect_timeout
    (bamboo_postmark) lib/bamboo/postmark_adapter.ex:51: Bamboo.PostmarkAdapter.deliver/2
    (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<0.115485522/0 in Bamboo.TaskSupervisorStrategy.deliver_later/3>
    Args: []

But I've set a high timeout.

@pablo-co
Copy link
Owner

pablo-co commented Jun 7, 2017

@joshuataylor recv_timeout is the timeout used when receiving a connection. connect_timeout is the timeout to establish a connection.

There is an issue related to this misunderstanding.

I'm guessing the confusion is because the HTTPoison option :timeout (which corresponds to hackney :connect_timeout) returns a :connect_timeout error, whereas the HTTPoison :recv_timeout returns the :timeout hackney error. So if you get a :timeout error from :recv_timeout occuring, you would probably think to increase the :timeout option, which goes to the wrong option.

So to fix it add connect_timeout to the request options.

config :my_app, MyApp.Mailer,
      adapter: Bamboo.PostmarkAdapter,
      request_options: [recv_timeout: 10_000, connect_timeout: 10_000] # 10 seconds

@joshuataylor
Copy link

Ah! That's obvious when pointed out, thank you so much for the explanation @pablo-co . Have you seen this at all? Could be because our servers are located in Australia, and could have minor latency spikes.

@pablo-co
Copy link
Owner

pablo-co commented Jun 8, 2017

It is the first time I have seen such an error actually happening, so that's a first. My guess is that there is probably an ISP in the middle causing the spikes. If you are inclined to find out if that is the case you can use traceroute whenever you see the spikes happening. 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants