Hello Dev Team,
This took some tracing :-(
I'm having a voice quality issue so I decided to create a reference wave file that could be played out by dialing a test number.
When I use winkstart to "Add Media" and select a large .wav file (~5M). The upload would fail but there is no indication via the GUI that anything went wrong.
I turned on debug logs and I see this:
2012-05-24 09:42:27.714 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_resource:71 (<0.12097.0>) OPTIONS: /v1/accounts/6ff4f0ab8bb5abd7c18d17cc65001312/media/675c90f5bb38406e6ca30616491efb9d/raw?<<>>
2012-05-24 09:42:27.715 [debug] |09d8c3140a08cd0294d2c35667b79513|crossbar_bindings:227 (<0.12122.0>) running fold for binding v1_resource.init
2012-05-24 09:42:27.729 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_util:334 (<0.12097.0>) mod accounts has params [<<"6ff4f0ab8bb5abd7c18d17cc65001312">>]
2012-05-24 09:42:27.751 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_util:334 (<0.12097.0>) mod media has params [<<"675c90f5bb38406e6ca30616491efb9d">>,<<"raw">>]
2012-05-24 09:42:27.751 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_util:112 (<0.12097.0>) undefined content type when getting req data
2012-05-24 09:42:27.751 [debug] |09d8c3140a08cd0294d2c35667b79513|crossbar_bindings:208 (<0.12123.0>) exact match <<"v1_resource.allowed_methods.media">> to <<"v1_resource.allowed_methods.media">>
2012-05-24 09:42:27.751 [debug] |09d8c3140a08cd0294d2c35667b79513|crossbar_bindings:204 (<0.12123.0>) sending routing v1_resource.allowed_methods.media to cb_media:allowed_methods
2012-05-24 09:42:27.752 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_util:293 (<0.12097.0>) sticking with method OPTIONS
2012-05-24 09:42:27.752 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_resource:130 (<0.12097.0>) allowing OPTIONS request for CORS preflight
2012-05-24 09:42:27.752 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_util:443 (<0.12097.0>) options requests are permitted by default
2012-05-24 09:42:27.752 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_util:462 (<0.12097.0>) ignore content type for options
2012-05-24 09:42:27.752 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_resource:187 (<0.12097.0>) is CORS request
2012-05-24 09:42:27.752 [debug] |09d8c3140a08cd0294d2c35667b79513|v1_resource:91 (<0.12097.0>) fulfilled in 37 ms
2012-05-24 09:42:27.897 [debug] |eee1ed1bbeef227d2cd0b7b4f5bf116e|v1_resource:71 (<0.12097.0>) POST: /v1/accounts/6ff4f0ab8bb5abd7c18d17cc65001312/media/675c90f5bb38406e6ca30616491efb9d/raw?<<>>
2012-05-24 09:42:27.897 [debug] |eee1ed1bbeef227d2cd0b7b4f5bf116e|crossbar_bindings:227 (<0.12126.0>) running fold for binding v1_resource.init
2012-05-24 09:42:27.910 [debug] |eee1ed1bbeef227d2cd0b7b4f5bf116e|v1_util:334 (<0.12097.0>) mod accounts has params [<<"6ff4f0ab8bb5abd7c18d17cc65001312">>]
2012-05-24 09:42:27.932 [debug] |eee1ed1bbeef227d2cd0b7b4f5bf116e|v1_util:334 (<0.12097.0>) mod media has params [<<"675c90f5bb38406e6ca30616491efb9d">>,<<"raw">>]
2012-05-24 09:42:27.932 [debug] |eee1ed1bbeef227d2cd0b7b4f5bf116e|v1_util:150 (<0.12097.0>) application/x-base64 content type when getting req data
2012-05-24 09:42:32.935 [error] <0.12097.0> ** Handler v1_resource terminating in rest_init/3
for the reason error:{case_clause,{error,timeout}}
** Options were []** Request was {http_req,#Port<0.46264>,cowboy_tcp_transport,keepalive,<0.12097.0>,'POST',{1,1},undefined,[<<"whistle">>,<<"kagesys">>,<<"com">>],undefined,<<"
whistle.kagesys.com">>,8000,[<<"v1">>,<<"accounts">>,<<"6ff4f0ab8bb5abd7c18d17cc65001312">>,<<"media">>,<<"675c90f5bb38406e6ca30616491efb9d">>,<<"raw">>],[<<"accounts">>,<<"6ff4f0ab8bb5abd7c18d17cc65001312">>,<<"media">>,<<"675c90f5bb38406e6ca30616491efb9d">>,<<"raw">>],<<"/v1/accounts/6ff4f0ab8bb5abd7c18d17cc65001312/media/675c90f5bb38406e6ca30616491efb9d/raw">>,undefined,<<>>,[{v1,<<"v1">>}],[{'Cache-Control',<<"no-cache">>},{'Pragma',<<"no-cache">>},{<<"Origin">>,<<"
http://whistle.kagesys.com">>},{'Content-Length',<<"6403924">>},{'Referer',<<"
http://whistle.kagesys.com/winkstart/">>},{<<"X-Auth-Token">>,<<"183738eeaaa5ddc5d7f9968d730f28f1">>},{'Content-Type',<<"application/x-base64; charset=UTF-8">>},{'Connection',<<"keep-alive">>},{<<"Dnt">>,<<"1">>},{'Accept-Language',<<"en-us,en;q=0.5">>},{'Accept',<<"application/json, text/javascript, */*; q=0.01">>},{'User-Agent',<<"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0">>},{'Host',<<"
whistle.kagesys.com">>}],[{'Connection',[<<"keep-alive">>]}],undefined,[],waiting,<<"data:audio/x-wav;base64,UklGRrBFAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YUBJSQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAAAAEAAQABgA0P/Q/+j/+P8AANj/4P/o/wAAwP/Q//D/WACQADgAyP/A/wAA6P+w/7D/4P8QAAAA4P/w/xAAKADQ/+D/AAAoADAACAAIABAAIAAYAAgAEAAQABAAAAAAAGgFuAOoB/AC8AVoA+gFcAOQBDgCgAPAALD8CAGg/Sj+0P9A/Qj+wP8Y/oj9iACQ/sD94PpQ+hD8EPxo/tD9mP5o/ij+4P0o/kj/yP5o/nj9kP3w/cj+mP5I/hD+8P1g/oD+4P4Y/0j/cP9o/5j/qP/g/xAAIAA4ADgASABQAGD/wP/w/6AAwACIAFgAYAB4AGgAiACYAKAAuACYALAAyADYAMgAyACwAMAAqAC4AMAA0ADYANAA2ADQALAAsACoALAAsACgAKAAkACIAIAAeABwAGgAYABgAFgAUABIAEgASABAADgAMAAwACgAIAAgABgAGAAQAAgACAAIAAgACAAAAPj/8P/w/+j/6P/o/+D/4P/Y/9j/2P/Y/+D/4...">>,...}
** Stacktrace: [{v1_util,decode_base64,3},{v1_resource,allowed_methods,2},{cowboy_http_rest,allowed_methods,2},{cowboy_http_rest,upgrade,4},{cowboy_http_protocol,upgrade_protocol,3}]
After some investigation I found that the problem is in cowboy_http_req:body/1
The timeout is hard coded to 5 seconds. It takes a lot longer than 5 secs to upload a 5Meg file. I increased it to 50000 and now it works fine.
body(Length, Req=#http_req{socket=Socket, transport=Transport,
body_state=waiting, buffer=Buffer}) ->
case Transport:recv(Socket, Length - byte_size(Buffer),
5000) of
{ok, Body} -> {ok, << Buffer/binary, Body/binary >>,
Req#http_req{body_state=done, buffer= <<>>}};
{error, Reason} -> {error, Reason}
end.
--
Alan R Evans
KAGE Systems Ltd
Tel:
+44 7891 773415