{"action":"closed","issue":{"url":"https://api.github.com/repos/ninenines/cowboy/issues/1269","repository_url":"https://api.github.com/repos/ninenines/cowboy","labels_url":"https://api.github.com/repos/ninenines/cowboy/issues/1269/labels{/name}","comments_url":"https://api.github.com/repos/ninenines/cowboy/issues/1269/comments","events_url":"https://api.github.com/repos/ninenines/cowboy/issues/1269/events","html_url":"https://github.com/ninenines/cowboy/issues/1269","id":303126003,"number":1269,"title":"cowboy_req:read_body(Req0) timeout","user":{"login":"loudferret","id":6190449,"avatar_url":"https://avatars1.githubusercontent.com/u/6190449?v=4","gravatar_id":"","url":"https://api.github.com/users/loudferret","html_url":"https://github.com/loudferret","followers_url":"https://api.github.com/users/loudferret/followers","following_url":"https://api.github.com/users/loudferret/following{/other_user}","gists_url":"https://api.github.com/users/loudferret/gists{/gist_id}","starred_url":"https://api.github.com/users/loudferret/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loudferret/subscriptions","organizations_url":"https://api.github.com/users/loudferret/orgs","repos_url":"https://api.github.com/users/loudferret/repos","events_url":"https://api.github.com/users/loudferret/events{/privacy}","received_events_url":"https://api.github.com/users/loudferret/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-03-07T14:45:29Z","updated_at":"2018-03-14T14:26:04Z","closed_at":"2018-03-14T14:26:04Z","author_association":"NONE","body":"Hello,\r\ncreating simple http-amqp gateway I have problem reading request body. Using function (mostly) copied from cowboy documentation\r\n```\r\nfetch_body(Rq) ->\r\n    case cowboy_req:has_body(Rq) of\r\n        true ->\r\n            {ok, Body} = fetch_body(Rq, <<>>),\r\n            Body;\r\n        false ->\r\n            <<>>\r\n    end.\r\n\r\nfetch_body(Req0, Acc) ->\r\n    case cowboy_req:read_body(Req0) of\r\n        {ok, Data, Req} ->\r\n            {ok, <<Acc/binary, Data/binary>>, Req};\r\n        {more, Data, Req} ->\r\n            fetch_body(Req, <<Acc/binary, Data/binary>>)\r\n    end.\r\n```\r\n\r\ntesting with simple `curl` request shell script\r\n\r\n```\r\n$ cat test/post.sh\r\n#!/bin/dash\r\n\r\ncurl -v -i --ipv4 \\\r\n    -H \"Content-Type: application/json\" \\\r\n    -X POST \\\r\n    --data @simple.json \\\r\n    'http://localhost:8567/mqw/v1/pub/raw'\r\n```\r\nThe file `simple.json` is 2 line textfile. Erlang error follows:\r\n\r\n```\r\n=CRASH REPORT==== 7-Mar-2018::15:38:45 ===\r\n  crasher:   \r\n    initial call: cowboy_stream_h:request_process/3\r\n    pid: <0.365.0>                             \r\n    registered_name: []            \r\n    exception exit: {{timeout,   \r\n                         {gen_server,call,\r\n                             [amqcwb_publish,\r\n                              {handle_http_request,\r\n                                  #{bindings => #{},      \r\n                                    body_length => 73,\r\n                                    has_body => true,\r\n                                    headers => #{<<\"accept\">> => <<\"*/*\">>,\r\n                                      <<\"content-length\">> => <<\"73\">>,\r\n                                      <<\"content-type\">> => <<\"application/json\">>,\r\n                                      <<\"host\">> => <<\"localhost:8567\">>,\r\n                                      <<\"user-agent\">> => <<\"curl/7.52.1\">>},\r\n                                    host => <<\"localhost\">>,\r\n                                    host_info => undefined,\r\n                                    method => <<\"POST\">>,      \r\n                                    path => <<\"/mqw/v1/pub/raw\">>,\r\n                                    path_info => undefined,\r\n                                    peer => {{127,0,0,1},57152},\r\n                                    pid => <0.364.0>,                                                                                                \r\n                                    port => 8567,            \r\n                                    qs => <<>>,\r\n                                    ref => http_server_cowboy,                                                                                                                                    \r\n                                    scheme => <<\"http\">>,                                                  \r\n                                    streamid => 1,\r\n                                    version => 'HTTP/1.1'},\r\n                                  []}]}},\r\n                     [{gen_server,call,2,[{file,\"gen_server.erl\"},{line,204}]},\r\n                      {cowboy_handler,execute,2,\r\n                          [{file,\r\n                               \"/home/x/work/DS/amqpCowboy/_build/default/lib/cowboy/src/cowboy_handler.erl\"},\r\n                           {line,37}]},\r\n                      {cowboy_stream_h,execute,3,\r\n                          [{file,\r\n                               \"/home/x/work/DS/amqpCowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl\"},\r\n                           {line,205}]},\r\n                      {cowboy_stream_h,request_process,3,\r\n                          [{file,\r\n                               \"/home/x/work/DS/amqpCowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl\"},\r\n                           {line,184}]},\r\n                      {proc_lib,init_p_do_apply,3,\r\n                          [{file,\"proc_lib.erl\"},{line,247}]}]}\r\n      in function  gen_server:call/2 (gen_server.erl, line 204)\r\n      in call from cowboy_handler:execute/2 (/home/x/work/DS/amqpCowboy/_build/default/lib/cowboy/src/cowboy_handler.erl, line 37)\r\n      in call from cowboy_stream_h:execute/3 (/home/x/work/DS/amqpCowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, line 205)\r\n      in call from cowboy_stream_h:request_process/3 (/home/x/work/DS/amqpCowboy/_build/default/lib/cowboy/src/cowboy_stream_h.erl, line 184)\r\n    ancestors: [<0.364.0>,<0.349.0>,<0.348.0>,ranch_sup,<0.297.0>]\r\n    messages: [{request_body,#Ref<0.0.2.317>,fin,73,\r\n                                <<\"{ \\\"empty\\\": {\\\"one\\\": 1, \\\"two\\\": \\\"two\\\"}, \\\"full\\\": {\\\"one\\\": 1, \\\"two\\\": \\\"three\\\"} }\">>}]\r\n    links: [<0.364.0>]\r\n    dictionary: []\r\n    trap_exit: false\r\n    status: running\r\n    heap_size: 987\r\n    stack_size: 27\r\n    reductions: 313\r\n  neighbours:\r\n```\r\n\r\nOutput from curl script:\r\n```\r\n*   Trying 127.0.0.1...\r\n* TCP_NODELAY set\r\n* Connected to localhost (127.0.0.1) port 8567 (#0)\r\n> POST /mqw/v1/pub/raw?from=meteo HTTP/1.1\r\n> Host: localhost:8567\r\n> User-Agent: curl/7.52.1\r\n> Accept: */*\r\n> Content-Type: application/json\r\n> Content-Length: 73\r\n>\r\n* upload completely sent off: 73 out of 73 bytes\r\n< HTTP/1.1 500 Internal Server Error\r\nHTTP/1.1 500 Internal Server Error\r\n< content-length: 0\r\ncontent-length: 0\r\n\r\n<\r\n* Curl_http_done: called premature == 0\r\n* Connection #0 to host localhost left intact\r\n```\r\n\r\nThe application is rebar3 app, I did try cowboy v2.0.0, v2.1.0 and v2.2.2 from hex.pm, application runs using `rebar3 shell`. Well, can you help me? Do you need more information?\r\n\r\n"}}
{"actor":{"display_login":"essen"}}