Node.js Paypal Payout API ECONNREFUSED Error - javascript

I try to use the PayPal payout API:
With this snippet:
var sync_mode = 'true';
paypal.payout.create(create_payout_json, sync_mode, function (error, payout) {
if (error) {
console.log("PayPal Error",error);
//throw error;
} else {
res.json(payout);
}
});
And gets this Error:
PayPal Error { [Error: connect ECONNREFUSED 173.0.82.78:443]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '173.0.82.78',
port: 443 }
Yesterday it worked perfectly, I didn't change something - what could cause the error?

Related

Connection between MariaDB and NodeJS not working

I'm using a vServer from Ionos for a little project. I installed a MariaDB and NodeJS. Currently I'm trying to connect them both. Here is my code:
const mariadb = require('mariadb');
const pool = mariadb.createPool({
host: 'localhost',
user:'root',
password: 'xxxxxxxxx',
database: 'christmastrees',
connectionLimit: 5,
});
async function asyncFunction() {
let conn;
try {
conn = await pool.getConnection();
const rows = await conn.query("SELECT * from bäume");
console.log(rows); //[ {val: 1}, meta: ... ]
} catch (err) {
throw err;
} finally {
if (conn) return conn.end();
}
}
But when executing the file (node app), I get an error message after a few seconds
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
From event:
at _registerHandshakeCmd (/root/server/node_modules/mariadb/lib/connection.js:745:11)
at /root/server/node_modules/mariadb/lib/connection.js:57:11
at new Promise (<anonymous>)
at Connection.connect (/root/server/node_modules/mariadb/lib/connection.js:56:16)
at createConnectionPoolPromise (/root/server/node_modules/mariadb/lib/pool-promise.js:31:8)
at creationTryout (/root/server/node_modules/mariadb/lib/pool-base.js:373:9)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
So I searched for help and after 2 hours I literally found only one Idea. I added this line of code to my connection...
port: '/var/run/mysqld/mysqld.sock'
I tryed again to use node app, but this time I didn't get an error message, it is loading forever and nothing happens.
I would be so grateful for any help...
So I found the solution to my problem.
I checked if my MariaDB Service is even running and no it wasn't ^^

Unable to catch ECONNRESET error and it is causing app to crash

I need help with socket.io-redis-adapter as their document on Client Error Handling seems to be gone.
I do not know how this error with Redis occur, has it got to do with Redis pub/sub? My redis server is in working error through out.
I've searched through forums and github. I've followed the recommended actions as follows. However, I'm still not able to catch the errors below, and it's causing my app to crash. My redis servers are all well and not disconnected at that time as I have other services using same server.
Can anyone provide me with some directions?
"#socket.io/redis-adapter": "^7.0.0",
"#socket.io/redis-emitter": "^4.1.0",
Catching error for both sub and pub client - Done ✅
// I'm using ioredis and I believe ioredis will auto handle reconnection?
pubClient.on("error", (err) => {
debug(`REDIS ADAPTOR DISCONNECTED ON pubClient %O`, err)
})
subClient.on("error", (err) => {
debug(`REDIS ADAPTOR DISCONNECTED ON subClient %O`, err)
})
Catch error on adapter - Done ✅
// But i think this is not working to catch errors ❌❌❌
io.of('/').adapter.on('error', function(error){
debug('error: ', error);
});
Ping to keep connection alive - Done ✅
setInterval(() => {
// emitter.of('/user').emit("time", new Date);
io.of('/user').emit("time", new Date())
}, 300000);
I've also tried using both node-redis and ioredis and both end up with same error below Done ✅
Manage to catch this with redis on error event ✅
socket REDIS ADAPTOR DISCONNECTED ON pubClient Error: read ECONNRESET
socket at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
socket errno: -54,
socket code: 'ECONNRESET',
socket syscall: 'read'
socket } +5h
socket error: Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
} +0ms
// Unable to catch this event ❌❌❌
// I think this causes my app to crash
events.js:292
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on RedisAdapter instance at:
at Redis.onError (/Users/Myname/Work/expressjs/api.singa.sg/node_modules/#socket.io/redis-adapter/dist/index.js:61:22)
at Redis.emit (events.js:327:22)
at Redis.EventEmitter.emit (domain.js:486:12)
at Redis.silentEmit (/Users/Myname/Work/expressjs/api.singa.sg/node_modules/ioredis/built/redis/index.js:544:26)
at Socket.<anonymous> (/Users/Myname/Work/expressjs/api.singa.sg/node_modules/ioredis/built/redis/event_handler.js:190:14)
at Object.onceWrapper (events.js:422:26)
at Socket.emit (events.js:327:22)
at Socket.EventEmitter.emit (domain.js:486:12)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
This is snippet of how my server is created;
....server declaration codes
const { createAdapter } = require("#socket.io/redis-adapter");
const Redis = require("ioredis");
const pubClient = new Redis({
host: process.env.SOCKET_IO_REDIS_HOST,
port: process.env.SOCKET_IO_REDIS_PORT,
username: process.env.SOCKET_IO_REDIS_USER,
password: process.env.SOCKET_IO_REDIS_PASSWORD,
db: process.env.SOCKET_IO_REDIS_DB,
})
const subClient = pubClient.duplicate();
const adapter = createAdapter(pubClient, subClient)
io.adapter(adapter)
pubClient.on("ready", () => {
debug(`REDIS ADAPTOR CONNECTED`)
})
pubClient.on("error", (err) => {
debug(`REDIS ADAPTOR DISCONNECTED ON pubClient %O`, err)
})
subClient.on("error", (err) => {
debug(`REDIS ADAPTOR DISCONNECTED ON subClient %O`, err)
})
pubClient.on("end", (err) => {
debug(`REDIS ADAPTOR ENDED %O`, err)
})
setInterval(() => {
// emitter.of('/user').emit("time", new Date);
io.of('/user').emit("time", new Date())
}, 300000);
io.of('/').adapter.on('error', function(error){
debug('error: ', error);
});

[SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3306

Hi I am new with Sequelize ORM. I am following some tutorial and while hands-on, I am facing the problem in connecting the MySQL database with server.
ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3306
at ConnectionManager.connect (G:\projects\chatApp\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:116:17)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
parent: Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
},
original: Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
}
}
Serve.js
const { ApolloServer } = require('apollo-server')
const { sequelize } = require('./models')
const resolvers = require('./graphql/resolvers')
const typeDefs = require('./graphql/typeDefs')
const server = new ApolloServer({
typeDefs,
resolvers,
})
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`)
sequelize
.authenticate()
.then(() => console.log('Database connected!!'))
.catch((err) => console.log(err))
})
config.json
{
"development": {
"username": "root",
"password": "root",
"database": "database_dev",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
Can anyone tell me why I am not able to connect to the database?
run MySql installer
reconfigure the MySql Server. it will work fine.
check this out
Check port of mysql you are using, maybe 3307 ?

Connecting to unix socket inside docker container using nodejs

I have written an app which connect to an already created unix.sock file and get some data from it. But I am getting EACCES error while try to connect. Error message is given below.
{ Error: connect EACCES /home/unix.sock
at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
errno: 'EACCES',
code: 'EACCES',
syscall: 'connect',
address: '/home/unix.sock' }
code snippet.
var socket = net.createConnection("/home/unix.sock")
.on("connect", function() {
console.log("Connected");
socket.write(req1);
socket.write(req2);
})
.on("data", function (data) {
data = JSON.parse(data);
console.log("Response from server: %s", data.response);
// Close the connection
socket.end();
})
.on('error', function(data) {
console.log(data);
})
Any idea about why this error occurs? I think it is because of the non root container. Is there anyway I can get rid of this error with non root container?

Node.js MSSQL 500: Internal Error. Details: ConnectionError: Failed to connect to DESKTOP-LK9JDJJ:1433 - connect ECONNREFUSED 192.168.99.1:1433

settings.js
exports.dbConfig = {
user: "gpolat",
password: "alphalpha",
server: "DESKTOP-LK9JDJJ",
database: "mydemo",
port: 1433
};
exports.webPort = 9000;
db.js
var sqlDb = require("mssql");
var settings = require("../settings");
exports.executeSql = function (sql, callback) {
var conn = new sqlDb.Connection(settings.dbConfig);
conn.connect()
.then(function () {
var req = new sqlDb.Request(conn);
req.query(sql)
.then(function (recordset) {
callback(recordset);
})
.catch(function (err) {
console.log(err);
callback(null, err);
});
})
.catch(function (err) {
console.log(err);
callback(null, err);
});
};
Console Error:
Debugger listening on 127.0.0.1:5858
Started Listening at: 9000
{ ConnectionError: Failed to connect to DESKTOP-LK9JDJJ:1433 - connect
ECONNREFUSED 192.168.99.1:1433
at Connection.<anonymous> (C:\Users\Gokhan\documents\visual studio
2015\Projects\SampleREST\SampleREST\node_modules\mssql\lib\tedious.js:378:25)
at Object.onceWrapper (events.js:290:19)
at emitOne (events.js:96:13)
at Connection.emit (events.js:188:7)
at Connection.socketError (C:\Users\Gokhan\documents\visual studio
Projects\SampleREST\SampleREST\node_modules\tedious\lib\connection.js:531:1
4)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
name: 'ConnectionError',
message: 'Failed to connect to DESKTOP-LK9JDJJ:1433 - connect ECONNREFUSED
192.168.99.1:1433',
code: 'ESOCKET' }
I get this error while creating the rest API via sql server.
"500: Internal Error. Details: ConnectionError: Failed to connect to DESKTOP-LK9JDJJ:1433 - connect ECONNREFUSED 192.168.99.1:1433"

Categories

Resources