我想httprc:request在我的 erlang 程序中调用,但出现异常,该异常没有给我任何信息,说明出了什么问题。
这是我的代码:
print_helloworld() ->
Body = "userId=12345",
httpc:request(post,
{
"'http://192.168.2.100:8080/010/xmppcontrol", [],
"application/x-www-form-urlencoded",
Body
}, [], []).
Run Code Online (Sandbox Code Playgroud)
这是我的例外:
1> hello_world:print_helloworld().
** exception exit: {noproc,
{gen_server,call,
[httpc_manager,
{request,
{request,undefined,<0.58.0>,0,'\'http',
{"192.168.2.100",8080},
"/010/xmppcontrol",[],post,
{http_request_h,undefined,"keep-alive",undefined,
undefined,undefined,undefined,undefined,undefined,
undefined,...},
{"application/x-www-form-urlencoded","userId=12345"},
{http_options,"HTTP/1.1",infinity,true,
{essl,[]},
undefined,false,infinity,...},
"'http://192.168.2.100:8080/010/xmppcontrol",[],none,
[],1510504662776,undefined,undefined,false}},
infinity]}}
in function gen_server:call/3 (gen_server.erl, line 214)
in call from httpc:handle_request/9 (httpc.erl, line 554)
Run Code Online (Sandbox Code Playgroud)
你能告诉我调用中有什么问题吗httpc:request?因为当我从 JS 调用 URL 时,它工作正常。
这是我的 JavaScript 代码:
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
asyncRequest = new XMLHttpRequest();
asyncRequest.addEventListener("readystatechange", stateChange, false);
asyncRequest.open('POST', 'http://192.168.2.100:8080/010/xmppcontrol?userId=' + userId , true);
asyncRequest.send(null);
Run Code Online (Sandbox Code Playgroud)
提前致谢。
错误消息表明没有正在运行的绑定到 name 的进程httpc_manager。如httpc和中所述inets,您需要inets 运行应用程序才能使 httpc 请求正常工作。您可以通过在使用 rebar 时将应用程序添加到应用程序列表(在 中src/....app.src)或手动启动inets应用程序来执行此操作,例如
inets:start(),
httpc:request(...).
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1078 次 |
| 最近记录: |