Refer to the NODEJS website to send an HTTP POST request method, the implementation of a simulated post submission function. The actual use of the Times socket hang up error.
Later found to be the problem with the request header settings, the sending option needs to add Headers field information (this estimate is also related to the other side of the server, for the unfinished POST request header, may be discarded).
The complete code is as follows (students who encounter type problems can do a reference):
varQueryString = Require (' querystring ')), HTTP= Require (' http ');vardata =querystring.stringify ({info:' Hi ', test:5});varopt ={hostname:' Www.test.com ', Port:9094, Path:'/perationsqlquery ', Method:' POST ', headers: {' Content-type ': ' application/x-www-form-urlencoded ', ' Content-length ': Data.length}};varreq = Http.request (OPT,function(res) {Res.on (' Data ',function(data) {Console.log (data.tostring ()); });}); Req.on (' Error ',function(e) {Console.log (' Problem with request: ' +e.message);}); Req.write (data); Req.end ();