{ok,RequestData,_} = rfc4627:decode(Arg#arg.clidata)
When it match the Output of
rfc4627:decode(Arg#arg.clidata)
to
{ok,RequestData,_}
it gives a {badmatch, ....} error
But I Copied the output in the error msg and matched to
{ok,RequestData,_}
in a erlang shell, Then it matches without any error.
This error only happens randomly. I can't figure out a reason. Sometimes it match and code works without any error. And sometimes it gives a error and yaws code crashes.
This is the error msg
<h2>Internal error, yaws code crashed</h2><br /><hr />
<pre>
ERROR erlang code threw an uncaught exception:
File: /usr/local/var/yaws/www/prime/yaws/session.yaws:1
Class: error
Exception: {badmatch,{ok,{obj,[{"action",<<"GET_SESSION_INFO">>}]},[]}}
Req: {http_request,'POST',{abs_path,"/prime/yaws/session.yaws"},{1,1}}
Stack: [{session,handle,2,
[{file,"/root/.yaws/yaws/default/session.erl"},{line,30}]},
{yaws_server,deliver_dyn_part,8,
[{file,"yaws_server.erl"},{line,2801}]},
{yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1215}]},
{yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1052}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]
</pre><hr />
Finally I've found the issue. I have 2 different interfaces in same server and both of them uses the same file with the same file name. but code inside is bit different. that's the problem. when I go to one interface it dynamically compiles the yaws and create an erl file in a temporary path. Then if I try to go to the other interface it does not compile the yaws again instead it refers the same erl file from the other interface because both files have the same name. The error occurs when it tries to match the request data comes from the interface. because that 2 interfaces send request data in 2 different formats.