File download timeout

56 views
Skip to first unread message

Ramkrishna Kulkarni

unread,
Aug 5, 2015, 6:16:29 AM8/5/15
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hello,

I'm running Nitrogen on Cowboy. Whenever I try to download a large file over slow internet, the download gets interrupted after some time and the file is downloaded partially.

Are there any file download timeout setting on Cowboy? I've not faced these issues on inets.

Thanks. 

Stuart Thackray

unread,
Aug 5, 2015, 10:59:30 AM8/5/15
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi Ramkrishna, 

I am not familiar with cowboy; but I had a similar issue but with uploads using yaws.

I found the problem was

keepalive_timeout default was 30 seconds. 


Hope that might help; or give you an idea where to look.


Regards,

Stuart

Jesse Gumm

unread,
Aug 6, 2015, 2:19:49 PM8/6/15
to nitrogenweb
Hi Ram,

When this download is failing, is it from a download in the static
directories (that is, using cowboy's built-in static handler), or is
it something dynamically generated by Nitrogen?

-Jesse
> --
> You received this message because you are subscribed to the Google Groups
> "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nitrogenweb...@googlegroups.com.
> To post to this group, send email to nitro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nitrogenweb.
> For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Ramkrishna Kulkarni

unread,
Aug 6, 2015, 10:40:34 PM8/6/15
to nitro...@googlegroups.com
Hi Jesse,

This is a dynamically generated file. Static files work fine. I tried to change timeouts (websocket_timeout) as suggested by Stuart but that didn't help.

I'm doing something like this:

download(Filename) ->
  {ok, Data} = file:read_file(Filename),
  wf:header("Content-Type", "application/octet-stream"),
  wf:header("Content-Transfer-Encoding", "binary"),
  wf:header("Accept-Ranges", "bytes"),
  wf:header("Content-Disposition", "filename=" ++ AttachmentName),
  Data.

Jesse Gumm

unread,
Aug 11, 2015, 7:36:09 AM8/11/15
to nitrogenweb

Thanks, I'm still looking into this one (I've been locked into a project late last week and over the weekend), so I'm not sure yet what's going on with the timeout, but I'll look into it.

How big of a dynamically generated response are we working with here? A couple megabytes?

Ramkrishna Kulkarni

unread,
Aug 11, 2015, 7:38:35 AM8/11/15
to nitro...@googlegroups.com
Thanks. The file is around 10 MB. It works on localhost properly but over a slow connection it breaks.

Stuart Thackray

unread,
Sep 11, 2015, 4:13:12 AM9/11/15
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi Ramkrishna,

Does the download stop after 100seconds? 

If this is the case i think you need to change cowboy_simple_bridge_sup the max_keepalive value here to the desired value.

http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_websocket/

Regards,
Stuart

Jesse Gumm

unread,
Sep 11, 2015, 12:09:43 PM9/11/15
to nitrogenweb
Good find, Stuart.

I'd love to hear if this solves it.

But I suspect an ideal solution might be to chunk larger dynamic
responses, which would get around having to fiddle with the keepalive.
But keepalive might be a good solution for the time-being.

-Jesse

On Fri, Sep 11, 2015 at 3:13 AM, Stuart Thackray

Stuart Thackray

unread,
Sep 11, 2015, 1:26:33 PM9/11/15
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi Jesse,

I had a similar problem with uploads (due to yaws limitation); cowboy not as well documented regarding configuration.

I configure yaws via yaws.conf btw even when setting this in the nitrogen/simple bridge configuration; it doesn't set yaws. 

if via the yaws.conf is it below or set to a different time.

keepalive_timeout = infinity


There are other options not passed through to YAWS via the config when embedded. Such as the max post size; you can check yaws_simple_bridge_sup.erl
http://yaws.hyber.org/yman.yaws?page=yaws_api

Should I come up with a list and do a pull request Jesse? I haven't spent time as embedded as limiting for me as one port and non nitrogen ports.

Regards,
Stuart

Jesse Gumm

unread,
Sep 11, 2015, 2:53:46 PM9/11/15
to nitrogenweb

That would be fantastic, I'd really appreciate that, Stuart!

--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Ramkrishna Kulkarni

unread,
Sep 30, 2015, 4:09:34 AM9/30/15
to nitro...@googlegroups.com
Sorry for the late reply.

It happens at around 30 seconds. I increased keepalive of Cowboy to 1000 but still breaks at around 30 seconds.

I'm going to check who's sending TCP SYN and update you back.

Thanks for the help.

Reply all
Reply to author
Forward
0 new messages