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?
Related
I want to access the Untis-API by using the npm package untis-api.
When I run the javascript file I get this error:
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
My Code:
const w = require("untis-api");
const e = w.entities;
w.connect("USERNAME", "PASSWORD", "SCHOOL", "URL").then(() => {
w.getTeachers().then(teachers => {
console.log(teachers);
}).catch(err => {
console.log(err);
});
w.logOut();
}).catch(err => {
console.log(err);
});
How can I fix this?
I'm using Node Version 16.15.0
It was an error at the webuntis server. Due to a DDoS Attack, the service was temporarily unavailable. This causes the error.
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);
});
I am working with LDAP JS. I am receiving ECONNRESET Error again and again, I also tried to browse it but no success. tried to add reconnect: true qualifier but no success. my code and error is as follows.
const adConfiguration = {
url: "ldap://" + process.env.ad_URL,
reconnect: true,
tlsOptions: {
rejectUnauthorized: true,
}
}
Error I am receiving is as follows:
Waiting for the debugger to disconnect...
events.js:353
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
at TCP.callbackTrampoline (internal/async_hooks.js:134:14)
Emitted 'error' event on Client instance at:
at Socket.onSocketError (F:\MFA\CrypLock_BE\CrypLockServer\node_modules\ldapjs\lib\client\client.js:966:12)
at Socket.emit (events.js:376:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
[nodemon] app crashed - waiting for file changes before starting...
You need to listen for the error on your ldap client instance and handle it:
const ldapjs = require('ldapjs')
const adConfiguration = {
url: "ldap://" + process.env.ad_URL,
reconnect: true,
tlsOptions: {
rejectUnauthorized: true,
}
}
const client = ldapjs.createClient(adConfiguration)
client.on('error', (err) => {
console.log(err.message) // this will be your ECONNRESET message
})
I recommend using some sort of abstraction around your raw ldap client so when you detect the error you can reset your client appropriately.
I've got a very small program in index.js, it tries to make a connection to a URL that does not exist, and makes a request within that connection. When that happens I want to catch and handle any errors, but I'm getting an ENOTFOUND raised and it forces my program to exit. How do I go about catching this error and handling it properly?
Index.js:
const jsforce = require("jsforce");
conn = new jsforce.Connection({
accessToken: "",
instanceUrl: "http://thisdoesnotexistalsdkfjalsdkfjasdlkfjasdlkfjalsdkfja.com",
version: "51.0",
callOptions: {
client: `sf-fx-runtime-nodejs-sdk-impl-v1:1`
}
});
const response = conn.query("SELECT foo from bar");
console.log(response);
response.then(
undefined,
function foo(e) {
console.log("======================== lol")
console.log(e)
})
Actual:
$ node index.js
/Users/rschneeman/Documents/projects/work/nodejs-uncatachable-error-maybe/node_modules/node-fetch/lib/index.js:1461
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
^
FetchError: request to http://thisdoesnotexistalsdkfjalsdkfjasdlkfjasdlkfjalsdkfja.com/services/data/v51.0/query?q=SELECT%20foo%20from%20bar failed, reason: getaddrinfo ENOTFOUND thisdoesnotexistalsdkfjalsdkfjasdlkfjasdlkfjalsdkfja.com
at ClientRequest.<anonymous> (/Users/rschneeman/Documents/projects/work/nodejs-uncatachable-error-maybe/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (node:events:369:20)
at Socket.socketErrorListener (node:_http_client:462:9)
at Socket.emit (node:events:369:20)
at emitErrorNT (node:internal/streams/destroy:188:8)
at emitErrorCloseNT (node:internal/streams/destroy:153:3)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
type: 'system',
errno: 'ENOTFOUND',
code: 'ENOTFOUND'
}
Expected:
$ node index.js
======================== lol
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
(logged but doesn't force exit the process)
Your case seems like a try/catch situation. You can do something like:
try {
//do stuff
catch (error) {
//handle your error
}
You might also want to take a look at Promises.
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?