logo
down
shadow

Configure request timeout in Phoenix?


Configure request timeout in Phoenix?

By : Kelechi
Date : November 19 2020, 03:01 PM
will be helpful for those in need This is by no means a responsibility of the web-server/framework. Cowboy has no clue (and it should not have!) about what’s going on in the application, it serves the connections. Phoenix could take care of that, but it would violate SRP. After all, the aforementioned timeout is more about the business logic. Imagine cowboy/phoenix would be trying to handle timeout: what should happen with the currently executing handler?
That said, the application should handle this kind of timeout and it’s relatively easy: one just needs to wrap the underlying execution in the task with a timeout you want. That way it would be flexible, reliable and you might specify which controllers/actions should behave that way, and which should not.
code :
def create(conn, params) do # or any other action
  fn -> prepare_result end
  |> Task.async()
  |> Task.yield(10)  # ⇐ HERE!!!
  |> case do
    {:ok, result} -> # success
      conn
      |> put_status(200)
      |> json(%{ok: result})
    nil -> # not finished yet; do smth with the task itself!
      conn
      |> put_status(503)
      |> json(%{error: :timeout})
    {:exit, reason} -> # should not happen [see Task.yield/2 docs]
      conn
      |> put_status(500) # internal server error; unexpected
      |> json(%{error: reason})
  end
end


Share : facebook icon twitter icon
Configure request timeout on heroku

Configure request timeout on heroku


By : GourdErwa
Date : March 29 2020, 07:55 AM
it should still fix some issue Heroku seems to encourage responses of 500ms or less. Since they don't mention altering the request timeout on that page my guess would be that they don't support changing it (though you could ask Heroku Support).
What kind of work are you doing for your report?
Configure request timeout for WebApi controllers

Configure request timeout for WebApi controllers


By : DoNotLikeIT
Date : March 29 2020, 07:55 AM
may help you . Good question, I would recommend to handle this from client side - you can always specify timeout settings in your consumer code, even if it is ajax:
code :
$.ajax({
url: "/ajax_json_echo/",
timeout: 1000,
...
How to configure Squid connection|read|write timeout per Request instead of Globally

How to configure Squid connection|read|write timeout per Request instead of Globally


By : Riggs
Date : March 29 2020, 07:55 AM
around this issue Important note: squid's behavior regarding timeouts can change depending on the protocol used. In the case of HTTPS, it cannot inspect the tunneled connection's HTTP headers so it cannot honor any of the Connection, Proxy-Connection, or Keep-Alive: timeout=xx values.
Scenario 1
Configure channel test timeout phoenix

Configure channel test timeout phoenix


By : SeXIT
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Phoenix.ChannelTest.join calls Phoenix.Channel.Server.socket/1 which makes a GenServer call to the channel with no configurable timeout to get the underlying socket from the GenServer's state. I believe since you send a message to self from your join function, that message is processed by the GenServer before the test code is able to get the socket value and since that call has the default timeout of 5 seconds, you get this timeout error.
A workaround for this would be to slightly delay the send to self using Process.send_after/3:
code :
Process.send_after(self(), {:sync, :database}, 100)
assert_push ..., ..., 10000
Configure Nginx connection timeout for specific request pattern

Configure Nginx connection timeout for specific request pattern


By : user3231426
Date : March 29 2020, 07:55 AM
Does that help Yes! One of the nice things about nginx is that you can set values in a hierarchy depending on locations, paths, parameters, source IP addresses ... basically on any metadata.
code :
server {
    listen 443 ssl http2;
    ....
    # default timeouts here
    proxy_connect_timeout <smallval>;
    proxy_send_timeout <smallval>;
    proxy_read_timeout <smallval>;

    location /biguploadshere {
        proxy_connect_timeout <bigval>;
        proxy_send_timeout <bigval>;
        proxy_read_timeout <bigval>;
    }
}
shadow
Privacy Policy - Terms - Contact Us © voile276.org