Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can increment send timeout in :cowboy.start_clear #1554

Closed
luongtt opened this issue Dec 18, 2021 · 3 comments
Closed

How can increment send timeout in :cowboy.start_clear #1554

luongtt opened this issue Dec 18, 2021 · 3 comments

Comments

@luongtt
Copy link

luongtt commented Dec 18, 2021

Hi,

We are experiencing failed file send download when using Cowboy 2.9. API will be download as failed when internet slow keep > 30s, success when <30s.

How we configure Cowboy in our Elixir project.

            ranch_opts = %{
              num_acceptors: 20,
              max_connections: :infinity,
              socket_opts: [
                {:port, 8080}
              ]
            }
            :cowboy.start_clear(:http, ranch_opts, %{env: %{dispatch: {:persistent_term, :dispatch}}})
            req = :cowboy_req.stream_reply(200, req)
            Enum.each(0..(chunk_size - 1), fn x ->
              content = read_chunk(path, x)
              :cowboy_req.stream_body(content, :nofin, req)
            end)
            content = read_chunk(path, chunk_size)
            :cowboy_req.stream_body(content, :fin, req)

Version:

Cowboy (2.9.0)
Elixir (1.12.3) 
Erlang/OTP 23
@essen
Copy link
Member

essen commented Dec 18, 2021

Sounds like you want to configure the idle_timeout protocol option.

@luongtt
Copy link
Author

luongtt commented Dec 18, 2021

Sounds like you want to configure the idle_timeout protocol option.

We try

:cowboy.start_clear(:http, ranch_opts, %{idle_timeout: 120_000, env: %{dispatch: {:persistent_term, :dispatch}}})

but this is not working

@essen
Copy link
Member

essen commented Dec 18, 2021

Do you perhaps have a proxy in-between that could be dropping the connection? You can use wireshark to see what's going on exactly, as well as Erlang tracing to see what Cowboy is doing (the cowboy_http module will be of particular interest).

@essen essen closed this as completed Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants