'Set request timeout at connection pool level using hackney and HTTPoison

I am using httpoison which uses Hackney under the hood to make HTTP requests.

By default, Hackney uses a default connection pool which is created with - connection timeout - 8000 ms, request timeout - 5000 ms. These numbers are too small for our project.

I have created a connection pool with different connection timeouts.

:hackney_pool.child_spec(:connection_pool, [timeout: 15_000, max_connections: 50])

and setting request timeout for each request like this

HTTPoison.get("httpbin.org/get", [], hackney: [recv_timeout: 15_000])

This does not look efficient to me as I need to put this timeout on every request.

I want to do set the recv_timeout at pool level eg:

:hackney_pool.child_spec(:connection_pool, [timeout: 15_000, recv_timeout: 15_000, max_connections: 50])

so when it creates a new connection, it can set the timeout at the connection level. My doubt is Can I specify the request timeout at the connection level? or is it just a request level timeout and HTTP does not support it at the connection level?.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source