小编Gho*_*4lk的帖子

httprc:request 抛出异常退出: {noproc, {gen_server,call, [httpc_manager ...]}}

我想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=' + …
Run Code Online (Sandbox Code Playgroud)

erlang httpc

2
推荐指数
1
解决办法
1078
查看次数

标签 统计

erlang ×1

httpc ×1