agentkeepalive icon indicating copy to clipboard operation
agentkeepalive copied to clipboard

Socket Hangup Issue

Open jAddict7 opened this issue 6 years ago • 0 comments

Dear Sir, Thanks for the awesome work. We have GPS server running Node JS, from where the co-ordinates are pushed to another server using HTTPS node module. Every second we need to send around 60-80 requests. Node JS is running out of memory, so on regular basis we restart the server. When we restart, requests are hanged for several hours and triggered only for every 5 seconds. And rest are hanged and not working. After some hours, it works fine even with high load of 80 requests per second.

const query = JSON.stringify({
	'device_id': XXX,
	'items': YYY,
});

const options = {
	hostname: 'HOST',
	port: 443,
	path: 'Page Link',
	method: 'POST',
	headers: {
		'Connection': 'keep-alive',
		'Content-Type': 'application/json',
		'Content-Length': query.length
	}
};

var request = https.request(options, (res) => {
	res.on('data', (data) => {
		console.log('Response Data :: '+data);
	}).on('end', () => {});
	res.on('error', (e) => {
		console.error('Response :: '+e);
	});
});

request.on('error', (e) => {
	console.error('Request :: '+e);
});
request.write(query);
request.end();

We request to the same URL. Is there any problem in the implementation? Will our module save us from the problem we are into? Please do guide us.

jAddict7 avatar Jan 01 '20 03:01 jAddict7