This is my code
const config = require('./config.json');
const {Telegraf} = require('telegraf');
// require('dotenv').config();
const bot = new Telegraf(config.BOT_TOKEN);
bot.use((ctx) => {
ctx.reply('Bot has started');
});
bot.launch()
every time I run this code it give me error and the error is
D:\Danish\Node testing\Node Bot Testing\node_modules\node-fetch\lib\index.js:1491
reject(new FetchError(request to ${request.url} failed, reason: ${err.message}, 'system', err));
^
FetchError: request to https://api.telegram.org/bot5121286363:[REDACTED]/getMe failed, reason: getaddrinfo ENOTFOUND api.telegram.org
at ClientRequest. (D:\Danish\Node testing\Node Bot Testing\node_modules\node-fetch\lib\index.js:1491:11)
at ClientRequest.emit (node:events:527:28)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
type: 'system',
errno: 'ENOTFOUND',
code: 'ENOTFOUND'
}
[nodemon] app crashed - waiting for file changes before starting...
Related
I am trying to spawn a python process from node.js as such:
const { spawn } = require('child_process');
const process = spawn('python', ['--version']);
But this throws an error:
$ node server2.js
node:events:346
throw er; // Unhandled 'error' event
^
Error: spawn python ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:81:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn python',
path: 'python',
spawnargs: [ '--version' ]
}
Why am I getting this error?
const process = spawn('python', ['--version']);
need to be changed to:
const process = spawn('python3', ['--version']);
const config = require('./config.json');
const logger = require('./utils/logger');
const Discord = require('discord.js');
const Statcord = require("statcord.js");
const { token } = require('./utils/variables.js');
const manager = new Discord.ShardingManager('./index.js', {
token: token,
autoSpawn: false,
totalShards: 5,
respawn: true,
spawnTimeout: -1
});
manager.on('shardCreate', shard => logger.info(`Launching Shard ${shard.id + 1}`, { label: `Neo Shard` }));
manager.spawn(manager.totalShards, 5500, -1);
Thats My Code of My Shard File
And I Run A Dashboard On The Same Instance
This Is The Error
2022-05-07 10:42:48 [info] [Neo Shard] Launching Shard 1
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
at ShardingManager._performOnShards (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:258:75)
at ShardingManager.fetchClientValues (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:245:17)
at Shard._handleMessage (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:338:22)
at ChildProcess.emit (node:events:527:28)
at emit (node:internal/child_process:938:14)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
(process:5992): GLib-GIO-WARNING **: 10:42:53.218: Unexpectedly, UWP app `Clipchamp.Clipchamp_2.2.12.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 46 extensions but has no verbs
2022-05-07 10:42:54 [info] [Neo Shard] Launching Shard 2
Dashboard is up and running on port 5003.
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
at ShardingManager._performOnShards (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:258:75)
at ShardingManager.fetchClientValues (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\ShardingManager.js:245:17)
at Shard._handleMessage (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:338:22)
at ChildProcess.emit (node:events:527:28)
at emit (node:internal/child_process:938:14)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
(process:20872): GLib-GIO-WARNING **: 10:42:58.757: Unexpectedly, UWP app `Clipchamp.Clipchamp_2.2.12.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 46 extensions but has no verbs
2022-05-07 10:42:59 [info] [Neo Shard] Launching Shard 3
node:events:505
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::5003
at Server.setupListenHandle [as _listen2] (node:net:1372:16)
at listenInCluster (node:net:1420:12)
at Server.listen (node:net:1508:7)
at Function.listen (C:\Teun\NeoSecurity\node_modules\express\lib\application.js:618:24)
at module.exports (C:\Teun\NeoSecurity\dashboard\dashboard.js:5243:9)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1399:8)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 5003
}
C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:158
reject(new Error('SHARDING_READY_DIED', this.id));
^
Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
at Shard.onDeath (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:158:16)
at Object.onceWrapper (node:events:642:26)
at Shard.emit (node:events:527:28)
at Shard._handleExit (C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:384:10)
at ChildProcess.emit (node:events:527:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Emitted 'error' event on Shard instance at:
at C:\Teun\NeoSecurity\node_modules\discord.js\src\sharding\Shard.js:392:49
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'SHARDING_READY_DIED'
}
I dont know how i can fix this i not that advanced
My dashboard is also in js en ejs.
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.
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"
Every now and then, as I'm requesting data from a github-issue, I get this error when firing my request-promise-function:
{ RequestError: Error: read ECONNRESET
at new RequestError (/vagrant/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/vagrant/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/vagrant/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/vagrant/node_modules/request/request.js:187:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:191:7)
at Request.onRequestError (/vagrant/node_modules/request/request.js:859:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at TLSSocket.socketErrorListener (_http_client.js:358:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:191:7)
at emitErrorNT (net.js:1283:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
From previous event:
at Request.plumbing.init (/vagrant/node_modules/request-promise-core/lib/plumbing.js:36:28)
at Request.RP$initInterceptor [as init] (/vagrant/node_modules/request-promise-core/configure/request2.js:41:27)
at new Request (/vagrant/node_modules/request/request.js:129:8)
at request (/vagrant/node_modules/request/index.js:54:10)
at module.exports (/vagrant/resources/GetIssuesData.js:25:9)
at Socket.<anonymous> (/vagrant/app.js:42:13)
at emitNone (events.js:86:13)
at Socket.emit (events.js:188:7)
at /vagrant/node_modules/socket.io/lib/socket.js:503:12
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'RequestError',
message: 'Error: read ECONNRESET',
cause:
{ Error: read ECONNRESET
at exports._errnoException (util.js:1029:11)
at TLSWrap.onread (net.js:575:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' },
error:
{ Error: read ECONNRESET
at exports._errnoException (util.js:1029:11)
at TLSWrap.onread (net.js:575:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' },
options:
{ uri: 'https://api.github.com/repos/1dv023/jp222vq-examination-3/issues?access_token=TOKEN',
headers:
{ 'User-Agent': 'me',
'Content-Type': 'application/x-www-form-urlencoded' },
simple: false,
reconnect: true,
callback: [Function: RP$callback],
transform: undefined,
resolveWithFullResponse: false,
transform2xxOnly: false },
response: undefined }
The request is fired every time a user requests a new page on the application, and is also fired when changes are made in the github-issue. The request feeds a socket-eventemitter with data. This is the request-function:
(function() {
let rp = require("request-promise");
module.exports = function(res, callback) {
let options = {
uri: "https://api.github.com/repos/" + res.issue,
headers: {
"User-Agent": "Me",
"Content-Type": "application/x-www-form-urlencoded"
},
simple: false,
reconnect: true
};
rp(options)
.then(function(body, err) {
try {
body = JSON.parse(body);
let context = {
issues: body.map(function(issue) {
return {
title: issue.title,
comments: issue.comments,
uploaded: issue.created_at,
updated: issue.updated_at,
link: "/" + issue.number
};
}),
};
callback(context, null);
} catch (e) {
throw new Error(e)
}
})
.catch(function(err) {
callback(null, err);
});
};
}());
I've been scratching my head for ages now, trying to understand why I get this error. Tried to read up on ECONNRESET, but didn't quite understand it. Can anybody please help?