From f95d2dd9e91d575c37033a418406ec2f61b28d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Thu, 29 Aug 2019 15:56:13 +0100 Subject: [PATCH] increase timeout for admin login --- backend/lib/backend/util.ex | 10 +++++----- .../backend_web/controllers/admin_login_controller.ex | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/lib/backend/util.ex b/backend/lib/backend/util.ex index 8102313..5485f7b 100644 --- a/backend/lib/backend/util.ex +++ b/backend/lib/backend/util.ex @@ -161,13 +161,13 @@ defmodule Backend.Util do @doc """ Gets and decodes a HTTP response. """ - @spec get_and_decode(String.t()) :: + @spec get_and_decode(String.t(), Atom.t(), Integer.t()) :: {:ok, any()} | {:error, Jason.DecodeError.t() | HTTPoison.Error.t()} - def get_and_decode(url) do + def get_and_decode(url, pool \\ :crawler, timeout \\ 15_000) do case HTTPoison.get(url, [{"User-Agent", get_config(:user_agent)}], - hackney: [pool: :crawler], - recv_timeout: 15_000, - timeout: 15_000 + hackney: [pool: pool], + recv_timeout: timeout, + timeout: timeout ) do {:ok, %{status_code: 200, body: body}} -> Jason.decode(body) {:ok, _} -> {:error, %HTTPoison.Error{reason: "Non-200 response"}} diff --git a/backend/lib/backend_web/controllers/admin_login_controller.ex b/backend/lib/backend_web/controllers/admin_login_controller.ex index a1c54fa..3b781f8 100644 --- a/backend/lib/backend_web/controllers/admin_login_controller.ex +++ b/backend/lib/backend_web/controllers/admin_login_controller.ex @@ -38,7 +38,12 @@ defmodule BackendWeb.AdminLoginController do def create(conn, %{"domain" => domain, "type" => type}) do cleaned_domain = clean_domain(domain) - {data_state, instance_data} = get_and_decode("https://#{cleaned_domain}/api/v1/instance") + + {data_state, instance_data} = + get_and_decode("https://#{cleaned_domain}/api/v1/instance", + pool: :admin_login, + timeout: 20_000 + ) error = cond do