Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 当尝试连接到服务器时,我得到一个断言'args[1]->;IsString()';失败错误_Node.js_Http_Alexa_Aws Cloud9 - Fatal编程技术网

Node.js 当尝试连接到服务器时,我得到一个断言'args[1]->;IsString()';失败错误

Node.js 当尝试连接到服务器时,我得到一个断言'args[1]->;IsString()';失败错误,node.js,http,alexa,aws-cloud9,Node.js,Http,Alexa,Aws Cloud9,我正在尝试使用node.js向Cloud9中的服务器发送帖子。使用Postmaster时,它可以正常工作。我已将其翻译为node.js并添加了http模块,因此我的相关代码如下所示: var http = require("http"); var options = { "method": "POST", "hostname": [ "192.168.153.188" ],

我正在尝试使用node.js向Cloud9中的服务器发送帖子。使用Postmaster时,它可以正常工作。我已将其翻译为node.js并添加了http模块,因此我的相关代码如下所示:

 var http = require("http");
 var options = {
            "method": "POST",
            "hostname": [
                "192.168.153.188"
            ],
            "port": "8080",
            "path": [
                "index.php"
            ],
            "headers": {
                "Content-Type": "text/plain",
                "cache-control": "no-cache",
                "Postman-Token": "19ed6137-291e-45e7-b4c3-04e62c0c89dc"
            }
        };

        var req = http.request(options, function(res) {
            var chunks = [];

            res.on("data", function(chunk) {
                chunks.push(chunk);
            });
            res.on("end", function() {
                var body = Buffer.concat(chunks);
                console.log(body.toString());
            });
        });
        req.end();
发送邮件时,我收到以下错误:

/var/lang/bin/node[1]: ../src/tcp_wrap.cc:247:static void node::TCPWrap::Connect(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `args[1]->IsString()' failed.
 1: node::Abort() [/var/lang/bin/node]
 2: node::Assert(char const* const (*) [4]) [/var/lang/bin/node]
 3: node::TCPWrap::Connect(v8::FunctionCallbackInfo<v8::Value> const&) [/var/lang/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/var/lang/bin/node]
 5: 0x55ccab57a28b [/var/lang/bin/node]
 6: 0x55ccab57ac27 [/var/lang/bin/node]
/var/lang/bin/node[1]:../src/tcp_wrap.cc:247:静态无效节点::TCPWrap::Connect(const v8::FunctionCallbackInfo&):断言“args[1]->IsString()”失败。
1:node::Abort()[/var/lang/bin/node]
2:node::Assert(char-const*const(*)[4])[/var/lang/bin/node]
3:node::TCPWrap::Connect(v8::FunctionCallbackInfo const&)[/var/lang/bin/node]
4:v8::internal::FunctionCallbackArguments::Call(void(*)(v8::FunctionCallbackInfo const&)[/var/lang/bin/node]
5:0x55ccab57a28b[/var/lang/bin/node]
6:0x55ccab57ac27[/var/lang/bin/node]
我已将节点更新为
v8.15
,尝试了
npm I natives
,因为这些解决方案对其他人有效,但我仍然得到相同的错误。 我也尝试过使用request和Unirest而不是http,但是连接在两者发生任何事情之前就超时了