aacerox / node-rest-client

REST API client from node.js
MIT License
377 stars 132 forks source link

Client is submitting the request again by itself after timeout time #174

Open ranupoju0126 opened 6 years ago

ranupoju0126 commented 6 years ago

HI,

below is my code **var options = {user: config.jobMonitor.user, password: config.jobMonitor.password} var client = new Client(options);

    var args = {
        data: postData,
        headers: {
            "test-header": "client-api",
            "Content-Type": "application/json"
        },
        requestConfig: {
            timeout: 120000, //request timeout in milliseconds
        },
        responseConfig: {
            timeout: 1000 //response timeout
        }

    }

var req = client.post(config.jobMonitor.uri, args, function (data, response) { pageResult.currentPage = parseInt(data.currentPageIndex); pageResult.count = parseInt(data.resultsCount); pageResult.jobs = data.jobDetails; pageResult.pages = parseInt(data.numberOfPages);

        if(response.statusCode == 200){
            pageResult.statusCode = response.statusCode;
            self.emit('send-data', pageResult);
        }

    });

    req.on('requestTimeout', function (req) {
        console.log('request has expired');
        self.emit('send-error','timeout')
        req.abort();
    });

    req.on('responseTimeout', function (res) {
        console.log('response has expired');

    });
    req.on('error', function (err) {
        console.log('request error');
    });
}**

after 120 seconds, its not timing out and the client is submitting the request again by itself image

Please see the above image.... after every 2 mins(120 seconds) there is a log for post data to client.