You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm implementing my nodejs server application with cluster, after successful this implementation my connection on android is not stable and reconnect every call sockets such as login, before implementation i don't have any problem and work fine
var cluster = require('cluster'), _portSocket = 3000, _portRedis = 6379, _HostRedis = 'localhost';
if (cluster.isMaster) {
var server = require('http').createServer(),
socketIO = require('socket.io').listen(server), redis = require('socket.io-redis');
socketIO.adapter(redis({host: _HostRedis, port: _portRedis}));
for (var i = 0; i < 4; i++) {
cluster.fork();
}
cluster.on('exit', function (worker, code, signal) {
if (!worker.suicide) {
cluster.fork();
}
});
}
if (cluster.isWorker) {
var http = require('http');
http.globalAgent.maxSockets = Infinity;
var socket = require('socket.io')(3000),
express = require('express'),
app = express(),
server = require('http').createServer(app),
io = socket.listen(server),
mysql = require('mysql'),
multer = require('multer'),
uuid = require('node-uuid'),
datetime = require('node-datetime'),
moment = require('moment'),
bcrypt = require('bcrypt'),
request = require('request'),
redis = require("redis-node"),
redisIo = require('socket.io-redis'),
email = require("emailjs"),
redisClient = redis.createClient(),
var connection =
mysql.createConnection(
{
host : 'localhost',
user : 'root',
password : 'a',
database : 'shoot',
multipleStatements: true
});
socket.adapter(redisIo({host: _HostRedis, port: _portRedis}));
socket.sockets.on('connection', function (socket, pseudo) {
socket.on('login', function (data) {
console.log(data.username);
login(data.username, data.password, function (success, value) {
if (success)
redisClient.set(data.username, socket.id);
socket.emit('login', {result: success, id: value});
});
});
socket.on('userConnected', function (data) {
...
});
});
}
function formatDate(date) {
...
}
function login(username, password, callback) {
...
}
after call login socket i dont see any log and doesnt work and cause of reconnect
The text was updated successfully, but these errors were encountered:
I'm implementing my nodejs server application with cluster, after successful this implementation my connection on android is not stable and reconnect every call sockets such as login, before implementation i don't have any problem and work fine
after call login socket i dont see any log and doesnt work and cause of reconnect
The text was updated successfully, but these errors were encountered: