Skip to content

Commit

Permalink
Fix recv_timeout for login requests
Browse files Browse the repository at this point in the history
5 seconds is too short for matrix.org
  • Loading branch information
progval committed Mar 27, 2024
1 parent 99da81d commit bb79c7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/matrix_client/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule M51.MatrixClient.Client do
# Check the server supports password login
url = base_url <> "/_matrix/client/r0/login"
Logger.debug("(raw) GET #{url}")
response = httpoison.get!(url, [], timeout: @timeout)
response = httpoison.get!(url, [], timeout: @timeout, recv_timeout: @timeout)
Logger.debug(Kernel.inspect(response))

case response do
Expand Down Expand Up @@ -111,7 +111,7 @@ defmodule M51.MatrixClient.Client do

url = base_url <> "/_matrix/client/r0/login"
Logger.debug("(raw) POST #{url} " <> Kernel.inspect(body))
response = httpoison.post!(url, body, [], timeout: @timeout)
response = httpoison.post!(url, body, [], timeout: @timeout, recv_timeout: @timeout)
Logger.debug(Kernel.inspect(response))

case response do
Expand Down
20 changes: 10 additions & 10 deletions test/matrix_client/client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:get!, fn url, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

%HTTPoison.Response{
status_code: 200,
Expand All @@ -53,7 +53,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:post!, fn url, body, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

assert Jason.decode!(body) == %{
"type" => "m.login.password",
Expand Down Expand Up @@ -104,7 +104,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:get!, fn url, headers, options ->
assert url == "https://example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

%HTTPoison.Response{
status_code: 404,
Expand Down Expand Up @@ -145,7 +145,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:get!, fn url, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

%HTTPoison.Response{
status_code: 200,
Expand All @@ -163,7 +163,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:post!, fn url, body, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

assert Jason.decode!(body) == %{
"type" => "m.login.password",
Expand Down Expand Up @@ -228,7 +228,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:get!, fn url, headers, options ->
assert url == "https://matrix.example.com/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

%HTTPoison.Response{
status_code: 200,
Expand All @@ -249,7 +249,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:post!, fn url, body, headers, options ->
assert url == "https://matrix.example.com/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

assert Jason.decode!(body) == %{
"type" => "m.login.password",
Expand Down Expand Up @@ -312,7 +312,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:get!, fn url, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

%HTTPoison.Response{
status_code: 200,
Expand Down Expand Up @@ -359,7 +359,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:get!, fn url, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

%HTTPoison.Response{
status_code: 200,
Expand All @@ -377,7 +377,7 @@ defmodule M51.MatrixClient.ClientTest do
|> expect(:post!, fn url, body, headers, options ->
assert url == "https://matrix.example.org/_matrix/client/r0/login"
assert headers == []
assert options == [timeout: @timeout]
assert options == [timeout: @timeout, recv_timeout: @timeout]

assert Jason.decode!(body) == %{
"type" => "m.login.password",
Expand Down

0 comments on commit bb79c7d

Please sign in to comment.