nithin
Request to phoenix server times out after 60 seconds
My api endpoint process the request for more than 60 seconds. Then empty reply is being sent to the client. How would I increase the request timeout? Thanks
Most Liked
outlog
it’s a new default in Cowboy 2 - can be changed using protocol_options - idle_timeout in the endpoint config
config :hello, HelloWeb.Endpoint,
http: [ port: 4000,
protocol_options: [idle_timeout: 5_000_000]
],...
NobbZ
This worked on my local clone of the linked repository:
$ time curl -v localhost:4001/api/test
* Trying ::1...
* TCP_NODELAY set
* connect to ::1 port 4001 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4001 (#0)
> GET /api/test HTTP/1.1
> Host: localhost:4001
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200 OK
< cache-control: max-age=0, private, must-revalidate
< content-length: 17
< content-type: application/json; charset=utf-8
< date: Wed, 13 Mar 2019 11:45:38 GMT
< server: Cowboy
< x-request-id: 2m5o42cfnvn7nmsujk0000e3
<
* Connection #0 to host localhost left intact
[{"test":"test"}]
The changes I did:
diff --git a/config/dev.exs b/config/dev.exs
index 6e25348..3e4b96d 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -7,7 +7,7 @@ use Mix.Config
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :demo, DemoWeb.Endpoint,
- http: [port: 4001],
+ http: [port: 4001, protocol_options: [idle_timeout: 70_000]],
debug_errors: true,
code_reloader: true,
check_origin: false,
outlog
yep, :infinity also works..
[idle_timeout: :infinity]
this issue also popped up here Video streaming connection closed automatically - one could argue for phoenix having :infinity as a default.. on the other hand 60 secs is a “sane” default..
would say there might be a need for an explicit config showing 60_000 as the configured.. the hidden default kinda falls into the implicit category - that I’m not a fan of..
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









