Error while sending request from web-server to game-server - node.js

Error: not opened at WebSocket.send
I have a piece of code on node server where i send the data to the game-server of my game.
pomelo.init({
host: rootTools.connectorHost,
port: rootTools.connectorPort,
log: true
}, function () {
var playerData = {any data of key value pair};
pomelo.request('connector.entryHandler.broadcastPlayer', {data: playerData, route: 'update', playerId: data.playerId}, function (err, data) {
console.log(err, data);
pomelo.disconnect();
});
});
While running on production there is a error Error: not opened
the console screenshot is -
[pomeloclient.init] websocket connected!
/home/digvijay/node_modules/ws/lib/WebSocket.js:181 else throw new
Error('not opened'); ^
Error: not opened at WebSocket.send
(/home/digvijay/node_modules/ws/lib/WebSocket.js:181:16) at send
(/home/digvijay/node_modules/pomelo-node-client-websocket/lib/pomelo-client.js:180:14)
at Object.handshake
(/home/digvijay/node_modules/pomelo-node-client-websocket/lib/pomelo-client.js:242:5)
The pomelo.init worked well as on consoles the websocket is connected.
I didn't get the issue in the code. Kindly describe the expected cause and suggestions on how to resolve is any.

Related

Error: read ECONNRESET while connection rabbitmq with nodejs

I've encountered following error message while connection our external RabbitMQ with NodeJS as follow:
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:205:27) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall: 'read'
}
and my nodejs code is as follow:
const amqp_url = "amqp://un:pw#sb-mq.com:9901/my-vhost";
amqp.connect(amqp_url, function (error0, connection) {
if (error0) {
throw error0;
}
connection.createChannel(function (error1, channel) {
if (error1) {
throw error1;
}
var queue = 'hello';
var msg = 'Hello World!';
channel.assertQueue(queue, {
durable: false
});
channel.sendToQueue(queue, Buffer.from(msg));
console.log(" [x] Sent %s", msg);
});
setTimeout(function () {
connection.close();
process.exit(0);
}, 500);
});
But the thing is when I've setup RabbidMQ locally with same configuration but using default port (like amqp://un:pw#localhost:5672/my-vhost), it was working perfectly. Please let me know how to troubleshoot that one, thanks.
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection.
see How do I debug error ECONNRESET in Node.js?
about RabbitMQ check if rabbitmq actually is active in that port, just:
telnet sb-mq.com 9901
from your client machine and check the firewall configuration.
You may have another service running on 9901
ECONNRESET is network problem, rabbitmq can work in different ports without problems
I found that issue has been resolved when I've tried to use amqps instead of amqp.

Unable to connect remote db2 with node js

I am trying to connect remote ibm db2 with node js in mac machine but I'm getting following error
[Error: [IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968
] {
error: '[node-ibm_db] SQL_ERROR',
sqlcode: -1598,
message: '[IBM][CLI Driver] SQL1598N An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968\n',
state: '42968'
}
And this is how I'm trying to connect
function db2Connection() {
var ibmdb = require('ibm_db');
var connStr = "DATABASE=dbname;HOSTNAME=mydb.ibm.com;UID=userid;PWD=password;PORT=447;PROTOCOL=TCPIP";
ibmdb.open(connStr, function (err,conn) {
if (err) return console.log(err);
conn.query('SELECT * FROM T_Name FETCH FIRST 6 ROWS ONLY', function (err, data) {
if (err) console.log(err);
else console.log(data);
conn.close(function () {
console.log('done');
});
});
});
}
db2Connection();
I went through some docs regarding that error but did not get any solution. Can anyone help on how to achieve this.

Error: All configured authentication methods failed levels: 'client-authentication'

I am using node.js ssh2 module.I have installed ssh2 module by executing the command 'npm install ssh2'.However, when I use ssh2 to connect to a remote server, it always output the error:
[Error: All configured authentication methods failed] levels: 'client-authentication'
This is my code
var Client = require('ssh2').Client
var conn = new Client();
var option = {
host: '10.171.65.154',
port: 22,
username: 'root',
password: '123456'
};
conn.on('ready', function(){
console.log('Client :: ready');
conn.sftp(function(err, sftp){
if(err) throw err;
sftp.readdir('home', function(err, list){
if(err) throw err;
console.dir(list);
conn.end();
});
});
}).on('error', function(err){
console.log(err);
}).connect(option);
However, I can not connect successfully.I am sure the username and password are correct and I can connect successfully by SecureCRT.
it always output the error:
[Error: All configured authentication methods failed] levels: 'client-authentication'
Probably, you have to handle keyboard-interactive authentication (which is not the same as password). Try something like this:
connection.on('ready', function(){
console.log("Connected!");
}).on('error', function(err){
console.error(err);
}).on('keyboard-interactive', function (name, descr, lang, prompts, finish) {
// For illustration purposes only! It's not safe to do this!
// You can read it from process.stdin or whatever else...
var password = "your_password_here";
return finish([password]);
// And remember, server may trigger this event multiple times
// and for different purposes (not only auth)
}).connect({
host: "your.host.or.ip",
port: 22,
username: "your_login",
tryKeyboard: true
});

Connecting to redis using kue always creates a connection to localhost

I can't connect to Redis using kue, I've followed this article, practically I'm creating the connection by using the kue redis client, and the connection code is this:
var kue = require('kue'),
redis = require('kue/node_modules/redis');
app.redisClient = redis.createClient('6379', 'remoteip',{});
app.redisClient.on('error', function (err) {
console.log('Redis error encountered', err);
});
app.redisClient.on('end', function() {
console.log('Redis connection closed');
});
kue.redis.createClient = function() {
console.log('client ------------------',app.redisClient);
return app.redisClient;
};
and it seems like Kue is trying to connect to a local Redis (which I don't have installed), because I'm getting this exception:
Error: Redis connection to 127.0.0.1:6379 failed - connect
ECONNREFUSED
I've read this post and it seems like the issue has been resolved in version 0.8 and I'm using 0.8.11 :/, finally I also wanted to override the client using a different client instance by using redis nodejs without any luck, because I'm getting the same error.
any help will be more than appreciated.
thanks!
I used a different way to setup the connection and it works so far this is what I've done:
app.redisClient = redis.createClient(config.redisPort, config.redisUrl,{});
app.redisClient.on('connect', function () {
console.info('successful connection to redis server');
});
app.redisClient.on('error', function (err) {
console.log('Redis error encountered', err);
});
app.redisClient.on('end', function() {
console.log('Redis connection closed');
});
kue.app.listen(config.kuePort);
app.jobs = kue.createQueue({
redis: {
createClientFactory: function(){
return app.redisClient;
}
}
});

Node.js Error : connect ECONN Refused

I am new to Node.js and am unable to resolve this error:
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect (as oncomplete) (net.js:892)
The code I was trying out follows :
var async = require('async'),
request = require('request');
function done(err,results) {
if (err) {
throw err;
}
console.log('Done ! results: %j',results);
}
var collection = [1,2,3,4];
function iterator(value,callback) {
request.post({
url: 'http://localhost:8080',
body: JSON.stringify(value)
}, function (err,res,body){
if (err) {
callback(err,body && JSON.parse(body));
}
});
}
async.map(collection,iterator,done);
ECONNREFUSED – Connection refused by server error
A port is being blocked can be the root cause of this issue, check if your connection is being blocked or even the changed default port can also cause this issue. Identify which app/service you are connecting to and its port is being blocked or changed.
And in your case check whether the application is hosted on port: 8080 or not.
But, this most likely occurs with FileZilla.

Resources