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

timeout in cowboy_simple_bridge:request_body/1 #41

Open
homeway opened this issue Dec 4, 2014 · 1 comment
Open

timeout in cowboy_simple_bridge:request_body/1 #41

homeway opened this issue Dec 4, 2014 · 1 comment

Comments

@homeway
Copy link

homeway commented Dec 4, 2014

when I use upload_element in nitrogen, there is a error report for simple_bridge as follow:

=INFO REPORT==== 4-Dec-2014::05:17:35 ===
Upload started.

=ERROR REPORT==== 4-Dec-2014::05:17:36 ===
Error in simple_bridge:make/2 - error - {case_clause,{error,timeout}}
[{cowboy_simple_bridge,request_body,1,
                       [{file,"/home/homeway/erlang/workspace/investors/lib/simple_bridge/src/cowboy_bridge_modules/cowboy_simple_bridge.erl"},
...

I read cowboy document and find this:

 body(Req, Opts) -> {ok, Data, Req2} | {more, Data, Req2}
...
 It will use a timeout of 15s per chunk.

When I deploy local project, and use local browser, the uploaded file with 2M size would uploaded in 15s, all the things worked well.
But when I deploy remote project the error report happened.

Though I change some code in simple_bridge:

%% cowboy_simple_bridge.el
request_body(ReqKey) ->
    {RequestCache, Req} = get_key(ReqKey),
    {Body, NewReq} = case RequestCache#request_cache.body of
        not_loaded ->
            %% We start with 2MB here, as headers and form fields will almost
            %% certainly be in the first 2mb of a request
-           case cowboy_req:body(Req, [{length, 2000000}]) of
+          case cowboy_req:body(Req, [{length, 2000000}, {read_timeout, 120000}]) of
...

It's bug in simple_bridge.
my solution can worked well now, but not pretty.
Perhaps it's a good idea set the timeout in simple_bridge.config.

@choptastic
Copy link
Member

Thanks. I'll get this fixed right away.

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