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.
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']);
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...
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.
Terminal Error:
> weather-app#1.0.0 devStart
> nodemon server.js
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
node:events:355
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1310:16)
at listenInCluster (node:net:1358:12)
at Server.listen (node:net:1445:7)
at Function.listen (/home/ivan-ilyich/Documents/dev/weather-app/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/ivan-ilyich/Documents/dev/weather-app/server.js:22:5)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1337:8)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
^C
ivan-ilyich#ivan-Ilyich:~/Documents/dev/weather-app$ kill
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
ivan-ilyich#ivan-Ilyich:~/Documents/dev/weather-app$ stop
Command 'stop' not found, but there are 18 similar ones.
ivan-ilyich#ivan-Ilyich:~/Documents/dev/weather-app$ npm stop devStart
npm ERR! missing script: stop
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ivan-ilyich/.npm/_logs/2021-02-26T14_02_05_736Z-debug.log
ivan-ilyich#ivan-Ilyich:~/Documents/dev/weather-app$ ^C
ivan-ilyich#ivan-Ilyich:~/Documents/dev/weather-app$ ^C
ivan-ilyich#ivan-Ilyich:~/Documents/dev/weather-app$ npm run devStart
> weather-app#1.0.0 devStart
> nodemon server.js
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
node:events:355
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1310:16)
at listenInCluster (node:net:1358:12)
at Server.listen (node:net:1445:7)
at Function.listen (/home/ivan-ilyich/Documents/dev/weather-app/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/ivan-ilyich/Documents/dev/weather-app/server.js:22:5)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1337:8)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
I'm new to programming and maybe my question is silly but I didn't found an answer from similar questions so I'll give it a try and post my own(sorry for my bad English, it's not my native language).
I'm working on a small tutorial weather app project but I'm forced to make it "my" way and I'm lost with the connection of the server and the client.
I keep getting that error: Fetch failed loading: "http://localhost:3000/weather"
Client side:
const searchElement = document.querySelector('[data-city-search]')
const searchBox = new google.maps.places.SearchBox(searchElement)
searchBox.addListener('places_changed', () => {
const place = searchBox.getPlaces()[0]
if (place == null) {
return
}
const latitude = place.geometry.location.lat()
const longitude = place.geometry.location.lng()
fetch('/weather', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
latitude: latitude,
longitude: longitude
})
})
.then(res => res.json())
.then(data => {
console.log(data);
// setWeatherData(data, place.formatted_address)
})
})
Server side:
if ( process.env.NODE_ENV !== 'production' ) {
require('dotenv').config()
}
const OPEN_WEATHER_API_KEY = process.env.OPEN_WEATHER_API_KEY
const express = require('express')
const app = express()
const axios = require('axios')
app.use(express.json())
app.use(express.static('public'))
app.post('/weather', (req, res) => {
const url = `api.openweathermap.org/data/2.5/weather?lat=${req.body.lat}&lon=${req.body.lon}&appid=${OPEN_WEATHER_API_KEY}`
axios({
url: url,
responseType: 'json'
})
.then(data => res.json(data.main))
})
app.listen(3000, () => {
console.log('Server Started!');
})
Just change fetch('/weather', { as fetch('http://localhost:3000/weather', {
You are hosting your api on port 3000 and trying to send a POST request to port 80
Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
at Promise.tap.then.catch.err (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:123:19)
From previous event:
at ConnectionManager.connect (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:120:13)
at sequelize.runHooks.then (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:311:50)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
From previous event:
at ConnectionManager._connect (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:311:8)
at ConnectionManager.getConnection (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:247:46)
at Promise.try (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:638:36)
From previous event:
at Promise.resolve.retry (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:629:53)
at /Users/wooseungjin/codlab-nodejs/node_modules/retry-as-promised/index.js:70:21
at new Promise (<anonymous>)
at retryAsPromised (/Users/wooseungjin/codlab-nodejs/node_modules/retry-as-promised/index.js:60:10)
at Promise.try (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:629:30)
From previous event:
at Sequelize.query (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:578:23)
at QueryInterface.dropTable (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/query-interface.js:254:27)
at Function.drop (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/model.js:1388:32)
at Promise.each.model (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:873:48)
From previous event:
at Sequelize.drop (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:873:20)
at Promise.try.then (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:798:21)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
From previous event:
at Sequelize.sync (/Users/wooseungjin/codlab-nodejs/node_modules/sequelize/lib/sequelize.js:796:8)
at Server.app.listen (/Users/wooseungjin/codlab-nodejs/app.js:16:33)
at Object.onceWrapper (events.js:286:20)
at Server.emit (events.js:198:13)
at emitListeningNT (net.js:1313:10)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
I got a problem with using a database (MySQL).
I want to link my web-server and database using express
but there's an error message which is
Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
Why does the error appear?
const Sequelize = require('sequelize');
const sequelize = new Sequelize('node_api_codelab', 'root', 'root',{
host: 'localhost',
dialect: "mysql" // pick one of 'mysql','sqlite','postgres','mssql',
});
const User = sequelize.define('user', {
name: Sequelize.STRING
});
module.exports = {
sequelize: sequelize,
User: User
}
the only reason for error that either your SQL server is not running or your node application don't have permission to access it
Check the mySql server status.
sudo service mysql status
or
ps aux | grep mysql
If your server is active Then ,
//Setting up the config
var sequelize = new Sequelize('your-database-name', 'db-username', 'db-password', {
host: 'localhost',
dialect: 'mysql' // pick one of 'mysql','sqlite','postgres','mssql',
port: 3306,
});
//Checking connection status
sequelize.authenticate().complete(function (err) {
if (err) {
console.log('There is connection in ERROR');
} else {
console.log('Connection has been established successfully');
}
});