Livebook timeout with httpoison

I have very simple livebook with setup like this

Mix.install([
  {:httpoison, "~> 2.0.0"},
  {:jason, "~> 1.4.0"}
])

and some code

url = "https://example.com/generate/image"
timeout = 60000
headers = [{"Content-Type", "application/json"}]
resp = HTTPoison.post!(url, payload, headers, timeout: timeout, recv_timout: timeout)

However, it seems like my requests timeout still after 5s instead of after 60s.

** (HTTPoison.Error) :timeout
    (httpoison 2.0.0) lib/httpoison.ex:261: HTTPoison.request!/5

I suppose the problem is that I did not set the timeout for hackney.
Any ideas how I can do that?
NOTE: I am so new to the livebook coding, that I could not even find how to stop the session and start from the beginning.

It sounds like you might be right. Perhaps this github issue helps? Timeout bigger than 5s does not work with hackney adapter · Issue #151 · elixir-tesla/tesla · GitHub

I also recommend trying Req — req v0.3.5 instead of httpoison, especially in a livebook setting for its simplicity.

1 Like

Thank you! I will try Req, thankfully this is very easy in a livebook.