Node.js data transfer

119 views Asked by At

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

There are 0 answers