Node.js数据传输

我正在将数据从节点传输到PHP。 我使用相同的URL来传输数据,并且可能需要在循环中调用它超过10次,但它只接受5次。 接下来的5将是错误(解析错误)。 如何解决?</ p>

代码</ p>

  function win_settings_fn(noos)
{

var str =“” ;
var len = str.length;
win_settings.headers = {'Content-length':len,'Content-Type':'application / x-www-form-urlencoded'}

var request = http.request(win_settings,function(response){
response.on('data',function(data){

var response = JSON.parse(data);

console.log( str +“respose ...........”+ noos);

});

response.on('error',function(err){

} );

response.on('end',function(){

});
});

request.on('error',function(err){\ n
console.log(“失败..............”+ noos);

});
request.write(str +“\ 0”);
request.end();

}
</ code> </ pre>

这是我正在使用的代码。< / p>

如果我打电话</ p>

  win_settings_fn(1)
win_settings_fn(2)
win_settings_fn(3)
win_settings_fn(4)
win_settings_fn(5 )
win_settings_fn(6)
win_settings_fn(7)
win_settings_fn(8)
win_settings_fn(9)
win_settings_fn(10)
</ code> </ pre>

结果是</ p>

  respose ........... 1 
respose ........... 2
respose ........... 3
respose ........... 4
respose ........... 5
failed .............. 6
failed .. ............ 7
failed .............. 8
failed .............. 9
。 .......... 10
</ code> </ pre>

为什么会这样? 发送数据有什么问题吗?</ p>
</ div>

展开原文

原文

I am transferring data from node to PHP. I am using same url to transfer data and may require to call it for more than 10 times in a loop, but it only accepts 5 times. The next 5 will be error (parse error). How to fix it?

code

function win_settings_fn(noos)
    {


                     var str="";
                     var len = str.length ;
                     win_settings.headers = {'Content-length' : len, 'Content-Type': 'application/x-www-form-urlencoded'}     

                     var request = http.request(win_settings, function (response) {
                     response.on('data', function (data) {


                        var response= JSON.parse(data);

                        console.log(str+"respose   ..........."+noos);


                     });

                     response.on('error', function (err) {

                     });

                     response.on('end', function () {

                                       });
                       });


                     request.on('error', function (err) {

                        console.log("failed.............."+noos);

                     });
                     request.write(str +"\0");
                     request.end();

              }

This is the code am using.

if I call

win_settings_fn(1)
win_settings_fn(2)
win_settings_fn(3)
win_settings_fn(4)
win_settings_fn(5)
win_settings_fn(6)
win_settings_fn(7)
win_settings_fn(8)
win_settings_fn(9)
win_settings_fn(10)

The result is

respose   ...........1
respose   ...........2
respose   ...........3
respose   ...........4
respose   ...........5
failed..............6
failed..............7
failed..............8
failed..............9
respose   ...........10

Why is it so? Is there any issue with sending the data?

dongliang1223
dongliang1223 听backlog设置?怎么样?我不确定
接近 6 年之前 回复
dongqi0644
dongqi0644 您可以检查您的php配置以获取最大客户端或监听积压设置。虽然解析错误似乎很奇怪。
接近 6 年之前 回复
dongmi1995
dongmi1995 我不知道。你有代码吗?
接近 6 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐