0

I have developed a chat application using node.js and socket.io. It was working fine till date, and suddenly it started giving me error as Connection lost: The server closed the connection..

Error: Connection lost: The server closed the connection.
at Protocol.end (/home/********/public_html/******/node_modules/mysql/lib/protocol/Protocol.js:109:13)
at Socket.<anonymous> (/home/******/public_html/*******/node_modules/mysql/lib/Connection.js:102:28)
at Socket.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:458:13)

The code i am using is as follows:

var app = require('express')();
app.set('port', process.env.PORT || 9000);
var server = require('http').Server(app);
var io = require('socket.io')(server);
var port = app.get('port');
var mysql = require('mysql');

var connection = mysql.createConnection({
 host     : 'localhost',
 user     : 'root',
 password : '',
 database : '****'
});

console.log(port);
connection.connect();
server.listen(port, process.env.IP);

I have used this solution. but still its giving me the same error.

Community
  • 1
  • 1

0 Answers0