2017-09-20 38 views
-2

我正在研究node.js,并将请求发布到远程服务器。服务器工作正常,因为我试图在邮递员上的API。但是下面的代码不会总是出现ECONNRESET错误。为什么?http.request总是收到ECONNRESET错误?

var http = require('http') 

sendSMS('...','【nodejs】您的验证码是1234') 

function sendSMS(phone,content){ 
    http.request({ 
     protocol:'http:', 
     host:'121.52.209.124', 
     port:'8888', 
     method:'post', 
     path:'/sms.aspx?action=send&userid=...&account=...&password=...&mobile='+phone+'&content='+encodeURIComponent(''+content) 
    }) 
} 

回答

0

一个end()方法应request()后调用。