javascriptnode.jstimeoutnode-soap

Nodejs Node-SOAP ETIMEDOUT after a few successful calls


i get an ETIMEDOUT error after a few successful calls... Here is the Code:

soap.createClient("./WSDL/test.wsdl", function (err, soapClient)
{
    if (err)
    {
         throw new Error(err)
    };

    bpData.forEach(function (elementOfArray)
    {
        soapClient.service.binding.Update({
             ProductUpload: {
                 ID: elementOfArray.ProductID,
                 newIndicator: 'false',
                 UpdateIndicator: 'true',
                 UpdateDate: dateFormat(new Date(), 'yyydd'),
                 RawData: elementOfArray.RawData1,
                 RawData2: elementOfArray.RawData2
             }
         }, function (err, result)
         {
               if (err)
               {
                   console.log(err);
                   //throw new Error(err);
                } else
                {
                    console.log(JSON.stringify(result));
                    return JSON.stringify(result);
                 }
            }
        );
.....

I already tried to set the timeout parameter up but nothing changed...

Thanks!


Solution

  • forEach is a sync function but soapClient.service.binding.Update is async meaning that you queue all requests in an instant. You should use async.js or create your own function to wait for the first request to finish to go to the second one.