http:request/5 returning wrong request and crashing
Vincent de Phily
vincent.dephily@REDACTED
Thu Jun 11 11:52:28 CEST 2009
Hi list,
I am making asynchronous http requests, sometimes close to one another a to a
server that may take a longer or shorter time to answer. But httpc eventually
returns the wrong answer (I start each request from a new process, and check
that the RequestId is correct), and ultimately crashes.
Attached files are the server code (running on apache mod_php), the client
code (running via escript), and the output with the error.
I'm now digging into the erlang http code, but if some smart erlanger on this
list can (check any that apply :p)
* confirm that I'm using the http module correctly
* reproduce the error
* find/fix the error in the http module
I'd be very gratefull.
Thank you.
--
Vincent de Phily
Mobile Devices
+33 (0) 666 301 306
+33 (0) 142 119 325
Warning
This message (and any associated files) is intended only for the use of its
intended recipient and may contain information that is confidential, subject
to copyright or constitutes a trade secret. If you are not the intended
recipient you are hereby notified that any dissemination, copying or
distribution of this message, or files associated with this message, is
strictly prohibited. If you have received this message in error, please
notify us immediately by replying to the message and deleting it from your
computer. Any views or opinions presented are solely those of the author
vincent.dephily@REDACTED and do not necessarily represent those of
the
company. Although the company has taken reasonable precautions to ensure no
viruses are present in this email, the company cannot accept responsibility
for any loss or damage arising from the use of this email or attachments.
-------------- next part --------------
ERROR got sleep:475773,req:22 instead of sleep:253855,req:36
ERROR got sleep:400962,req:23 instead of sleep:892698,req:48
ERROR got sleep:609265,req:44 instead of sleep:666946,req:46
ERROR got sleep:809604,req:37 instead of sleep:561590,req:43
ERROR got sleep:48275,req:40 instead of sleep:583062,req:79
ERROR got sleep:309693,req:24 instead of sleep:19887,req:69
ERROR got sleep:58650,req:25 instead of sleep:165858,req:83
ERROR got sleep:876102,req:47 instead of sleep:236006,req:84
ERROR got sleep:294143,req:51 instead of sleep:116891,req:100
ERROR got sleep:666946,req:46 instead of sleep:265132,req:76
ERROR got sleep:561590,req:43 instead of sleep:134661,req:82
ERROR got sleep:578814,req:26 instead of sleep:333639,req:87
ERROR got sleep:265132,req:76 instead of sleep:334454,req:102
ERROR got sleep:334454,req:102 instead of sleep:535188,req:116
ERROR got sleep:583062,req:79 instead of sleep:24666,req:103
ERROR got sleep:719828,req:52 instead of sleep:911082,req:134
ERROR got sleep:134661,req:82 instead of sleep:773815,req:133
ERROR got sleep:24666,req:103 instead of sleep:139471,req:136
ERROR got sleep:400772,req:53 instead of sleep:867834,req:149
ERROR got sleep:535188,req:116 instead of sleep:220863,req:132
ERROR got sleep:989294,req:27 instead of sleep:753863,req:110
ERROR got sleep:183676,req:29 instead of sleep:140469,req:155
ERROR got sleep:220863,req:132 instead of sleep:78155,req:152
ERROR got sleep:78155,req:152 instead of sleep:548799,req:161
ERROR got sleep:202757,req:30 instead of sleep:181404,req:163
ERROR got sleep:773815,req:133 instead of sleep:327887,req:137
ERROR got sleep:33599,req:31 instead of sleep:482978,req:172
ERROR got sleep:139471,req:136 instead of sleep:46808,req:171
ERROR got sleep:793855,req:54 instead of sleep:904511,req:186
ERROR got sleep:74423,req:55 instead of sleep:579316,req:191
ERROR got sleep:548799,req:161 instead of sleep:686473,req:166
ERROR got sleep:327887,req:137 instead of sleep:314327,req:179
ERROR got sleep:46808,req:171 instead of sleep:755194,req:197
ERROR got sleep:26543,req:213 instead of sleep:120616,req:214
ERROR got sleep:393300,req:56 instead of sleep:461674,req:212
ERROR got sleep:314327,req:179 instead of sleep:600785,req:199
ERROR got sleep:120616,req:214 instead of sleep:955584,req:216
ERROR got sleep:889027,req:32 instead of sleep:811871,req:173
ERROR got sleep:686473,req:166 instead of sleep:99423,req:195
ERROR got sleep:99423,req:195 instead of sleep:777027,req:229
ERROR got sleep:597835,req:57 instead of sleep:158049,req:217
ERROR got sleep:755194,req:197 instead of sleep:440344,req:218
ERROR got sleep:836914,req:33 instead of sleep:781901,req:225
ERROR got sleep:955584,req:216 instead of sleep:520411,req:231
ERROR got sleep:777027,req:229 instead of sleep:847124,req:234
ERROR got sleep:644213,req:59 instead of sleep:773020,req:238
ERROR got sleep:600785,req:199 instead of sleep:685726,req:243
ERROR got sleep:828876,req:34 instead of sleep:27102,req:249
ERROR got sleep:440344,req:218 instead of sleep:579362,req:265
ERROR got sleep:601217,req:62 instead of sleep:534866,req:259
=ERROR REPORT==== 11-Jun-2009::11:20:30 ===
** Generic server <0.63.0> terminating
** Last message in was {tcp,#Port<0.963>,
<<"HTTP/1.1 200 OK\r\nDate: Thu, 11 Jun 2009 09:20:30 GMT\r\nServer: Apache\r\nX-Powered-By: PHP/5.2.9-pl2-gentoo\r\nContent-Length: 1090\r\nKeep-Alive: timeout=15, max=89\r\nConnection: Keep-Alive\r\nContent-Type: text/plain\r\n\r\nsleep:1744,req:63\nslept for 1744 usec\nArray\n(\n [sleep] => 1744\n [data] => sleep:1744,req:63\n)\nArray\n(\n [UNIQUE_ID] => SjDMXn8AAAEAAGFnP9YAAAB9\n [HTTP_TE] => \n [HTTP_HOST] => 127.0.0.1\n [HTTP_CONNECTION] => keep-alive\n [PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin\n [SERVER_SIGNATURE] => <address>Apache Server at 127.0.0.1 Port 80</address>\n\n [SERVER_SOFTWARE] => Apache\n [SERVER_NAME] => 127.0.0.1\n [SERVER_ADDR] => 127.0.0.1\n [SERVER_PORT] => 80\n [REMOTE_ADDR] => 127.0.0.1\n [DOCUMENT_ROOT] => /var/www/localhost/htdocs\n [SERVER_ADMIN] => root@REDACTED\n [SCRIPT_FILENAME] => /var/www/localhost/htdocs/sleep.php\n [REMOTE_PORT] => 39719\n [GATEWAY_INTERFACE] => CGI/1.1\n [SERVER_PROTOCOL] => HTTP/1.1\n [REQUEST_METHOD] => GET\n [QUERY_STRING] => sleep=1744&data=sleep:1744,req:63\n [REQUEST_URI] => /sleep.php?sleep=1744&data=sleep:1744,req:63\n [SCRIPT_NAME] => /sleep.php\n [PHP_SELF] => /sleep.php\n [REQUEST_TIME] => 1244712030\n)\n">>}
** When Server state == {state,undefined,
{tcp_session,
{{"127.0.0.1",80},<0.63.0>},
false,http,#Port<0.963>,1,keep_alive},
undefined,undefined,undefined,undefined,
{[],[]},
{[],[]},
keep_alive,[],nolimit,nolimit,
{options,
{undefined,[]},
0,2,5,120000,2,disabled,enabled,false},
{timers,[],#Ref<0.0.0.1227>},
httpc_manager_myprofile,undefined}
** Reason for termination ==
** {function_clause,
[{httpc_handler,handle_info,
[{tcp,#Port<0.963>,
<<"HTTP/1.1 200 OK\r\nDate: Thu, 11 Jun 2009 09:20:30 GMT\r\nServer: Apache\r\nX-Powered-By: PHP/5.2.9-pl2-gentoo\r\nContent-Length: 1090\r\nKeep-Alive: timeout=15, max=89\r\nConnection: Keep-Alive\r\nContent-Type: text/plain\r\n\r\nsleep:1744,req:63\nslept for 1744 usec\nArray\n(\n [sleep] => 1744\n [data] => sleep:1744,req:63\n)\nArray\n(\n [UNIQUE_ID] => SjDMXn8AAAEAAGFnP9YAAAB9\n [HTTP_TE] => \n [HTTP_HOST] => 127.0.0.1\n [HTTP_CONNECTION] => keep-alive\n [PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin\n [SERVER_SIGNATURE] => <address>Apache Server at 127.0.0.1 Port 80</address>\n\n [SERVER_SOFTWARE] => Apache\n [SERVER_NAME] => 127.0.0.1\n [SERVER_ADDR] => 127.0.0.1\n [SERVER_PORT] => 80\n [REMOTE_ADDR] => 127.0.0.1\n [DOCUMENT_ROOT] => /var/www/localhost/htdocs\n [SERVER_ADMIN] => root@REDACTED\n [SCRIPT_FILENAME] => /var/www/localhost/htdocs/sleep.php\n [REMOTE_PORT] => 39719\n [GATEWAY_INTERFACE] => CGI/1.1\n [SERVER_PROTOCOL] => HTTP/1.1\n [REQUEST_METHOD] => GET\n [QUERY_STRING] => sleep=1744&data=sleep:1744,req:63\n [REQUEST_URI] => /sleep.php?sleep=1744&data=sleep:1744,req:63\n [SCRIPT_NAME] => /sleep.php\n [PHP_SELF] => /sleep.php\n [REQUEST_TIME] => 1244712030\n)\n">>},
{state,undefined,
{tcp_session,
{{"127.0.0.1",80},<0.63.0>},
false,http,#Port<0.963>,1,keep_alive},
undefined,undefined,undefined,undefined,
{[],[]},
{[],[]},
keep_alive,[],nolimit,nolimit,
{options,
{undefined,[]},
0,2,5,120000,2,disabled,enabled,false},
{timers,[],#Ref<0.0.0.1227>},
httpc_manager_myprofile,undefined}]},
{gen_server,handle_msg,5},
{proc_lib,init_p_do_apply,3}]}
ERROR got sleep:966340,req:222 instead of sleep:41561,req:283
ERROR got sleep:847124,req:234 instead of sleep:452924,req:260
ERROR got sleep:328018,req:35 instead of sleep:38465,req:287
ERROR got sleep:253855,req:36 instead of sleep:752560,req:298
ERROR got sleep:449731,req:228 instead of sleep:482324,req:314
ERROR got sleep:452924,req:260 instead of sleep:836953,req:297
ERROR got sleep:685726,req:243 instead of sleep:704916,req:289
ERROR got sleep:520411,req:231 instead of sleep:779911,req:336
ERROR got sleep:579362,req:265 instead of sleep:573722,req:321
ERROR got sleep:892698,req:48 instead of sleep:623977,req:310
ERROR got sleep:19887,req:69 instead of sleep:884027,req:355
ERROR got sleep:836953,req:297 instead of sleep:206028,req:317
ERROR got sleep:165858,req:83 instead of sleep:700816,req:357
ERROR got sleep:538706,req:253 instead of sleep:607225,req:370
ERROR got sleep:206028,req:317 instead of sleep:267166,req:359
ERROR got sleep:333639,req:87 instead of sleep:27437,req:363
^C^C
-------------- next part --------------
#!/usr/bin/env escript
%-mode(compile).
main(_Args) ->
Profile = myprofile,
ok = inets:start(),
{ok, _ProfilePid} = inets:start(httpc, [{profile, Profile}]),
loop(Profile).
loop(Profile) ->
loop(Profile, 1).
loop(Profile, Req) ->
Sleep = random:uniform(1000000),
Data = "sleep:" ++ integer_to_list(Sleep) ++ ",req:" ++ integer_to_list(Req),
runreq(Profile, Sleep, Data),
receive after Sleep div 100000 -> ok end,
loop(Profile, Req + 1).
runreq(Profile, Sleep, Data) ->
spawn(fun() ->
case http:request(get, {"http://127.0.0.1/sleep.php?sleep=" ++ integer_to_list(Sleep) ++ "&data=" ++ Data, []}, [], [{sync, false}], Profile) of
{ok, HttpRef} ->
receive
{http, {HttpRef, {{_, _HttpCode, _}, _, HttpData}}} ->
case re:run(HttpData, "^.*$", [multiline, {capture, first, list}]) of
{match, [FirstLine]} ->
case FirstLine of
Data ->
ok;
%io:format("OK ~s\n", [Data]);
_ ->
io:format("ERROR got ~s instead of ~s~n", [FirstLine, Data])
end;
Err2 ->
io:format("ERROR cant match firstline ~p~n", [Err2])
end;
{error, Err3} ->
io:format("ERROR http receive failure ~p~n", [Err3])
after
10000 ->
ok = http:cancel_request(HttpRef, Profile),
io:format("ERROR http timeout failure~n", [])
end;
{error, Err4} ->
io:format("ERROR http request failure ~p~n", [Err4])
end
end).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sleep.php
Type: application/x-php
Size: 166 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20090611/a49391d1/attachment.bin>
More information about the erlang-bugs
mailing list