drymoeuka282427675 2014-11-17 09:13
浏览 29

Node.js数据传输

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题