So have read these 2 similar questions
Immediately after the first (and only) Socket.IO connection my Node.js server application quits. But not every time, it seems to happen randomly which makes it more difficult to troubleshoot.
Have Node v 10.16.3 installed in Windows 10.
Can any Node.js experts suggest some troubleshooting steps?
This is the relevant portion of my Node Server app
var nodemailer = require('nodemailer');
var sgTransport = require('nodemailer-sendgrid-transport');
const os = require('os');
var exec = require('exec');
var child_process = require('child_process');
console.log(os.release());
var options = {
auth: {
api_key: 'my key here'
}
}
var mailer = nodemailer.createTransport(sgTransport(options));
//socket.IO code
var port = 3000;
var sys = require('util');
var express = require('express');
var app = express();
app
.use(express.static(__dirname + '/public'))
.get('/', function (req, res) {
res.write('API');
res.send('Hello World');
});
var server = app.listen(port);
var io = require('socket.io');
var sockIO = io.listen(server);
//sockIO.set('heartbeats',false);
//sockIO.set('heartbeat timeout', 1280);
sockIO.sockets.on('connection', function (socket) {
// new client is here!
console.log('YES SERVER IS RUNNING and __dirname is' + __dirname);
var APP = this;
For package dependencies
"dependencies": {
"exec": "^0.2.1",
"express": "^4.16.2",
"nodemailer": "^2.7.2",
"nodemailer-sendgrid-transport": "^0.2.0",
"sendgrid": "^4.10.0",
"socket.io": "^1.7.4"
}