Getting This Error When Trying To Connect To MongoDB database - javascript

codeNot sure why Im getting this error as it was working the last time I opened my project but this is what I get when I attempt to connect to my database.mongo error,jpg
Error Code
PS C:\Users\Joseph\Desktop\server> node server.js
Server is running on port:${port}
(node:18576) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to
the MongoClient constructor.
(Use `node --trace-deprecation ...` to show where the warning was created)
C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\topologies\server.js:438
new MongoNetworkError(
^
MongoNetworkError: failed to connect to server [cluster0-shard-00-02.qqrcr.mongodb.net:27017] on first connect [MongoError: bad auth : Authentication failed.
at Connection.messageHandler (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:359:19)
at Connection.emit (node:events:379:20)
at processMessage (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:451:10)
at TLSSocket.<anonymous> (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:620:15)
at TLSSocket.emit (node:events:379:20)
at addChunk (node:internal/streams/readable:313:12)
at readableAddChunk (node:internal/streams/readable:288:9)
at TLSSocket.Readable.push (node:internal/streams/readable:227:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {
ok: 0,
code: 8000,
codeName: 'AtlasError'
}]
at Pool.<anonymous> (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\topologies\server.js:438:11)
at Pool.emit (node:events:379:20)
at C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\pool.js:562:14
at C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\pool.js:1009:9
at callback (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connect.js:75:5)
at C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connect.js:147:27
at C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\auth\scram.js:185:14
at _callback (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:328:7)
at Connection.messageHandler (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:359:9)
at Connection.emit (node:events:379:20)
at processMessage (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:451:10)
at TLSSocket.<anonymous> (C:\Users\Joseph\Desktop\node_modules\mongodb\lib\core\connection\connection.js:620:15)
at TLSSocket.emit (node:events:379:20)
at addChunk (node:internal/streams/readable:313:12)
at readableAddChunk (node:internal/streams/readable:288:9)
at TLSSocket.Readable.push (node:internal/streams/readable:227:10)
PS C:\Users\Joseph\Desktop\server>

Related

Error trying to build androidjs - it says 'folder already exists'

I'm trying to build my first project using androidjs
I'm getting the following error message
Failed to create assets Error: EEXIST: file already exists, mkdir 'C:\Users\BenjaminShumway\.androidjs\cache\androidjs-sdk\assets\myapp'
at Object.mkdirSync (node:fs:1395:3)
at Webview.updateFiles (C:\Users\BenjaminShumway\AppData\Roaming\npm\node_modules\androidjs-builder\modules\webview.js:320:20)
at C:\Users\BenjaminShumway\AppData\Roaming\npm\node_modules\androidjs-builder\modules\webview.js:511:26
at Request.<anonymous> (C:\Users\BenjaminShumway\AppData\Roaming\npm\node_modules\androidjs-builder\modules\webview.js:663:17)
at Request.emit (node:events:525:35)
at IncomingMessage.<anonymous> (C:\Users\BenjaminShumway\AppData\Roaming\npm\node_modules\androidjs-builder\node_modules\request\request.js:1076:12)
at Object.onceWrapper (node:events:627:28)
at IncomingMessage.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4075,
syscall: 'mkdir',
code: 'EEXIST',
path: 'C:\\Users\\BenjaminShumway\\.androidjs\\cache\\androidjs-sdk\\assets\\myapp'
}

got packets out of order. Expected 3 but received 0

server is crashing automatically and showing this error. can you guys please me to get out from this problem>>>>
Warning: got packets out of order. Expected 3 but received 0
node:events:368
throw er; // Unhandled 'error' event
^
Error: The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.
at Connection.protocolError (/home/abroadinquiry/server/node_modules/mysql2/lib/connection.js:394:17)
at Connection.handlePacket (/home/abroadinquiry/server/node_modules/mysql2/lib/connection.js:445:14)
at PacketParser.onPacket (/home/abroadinquiry/server/node_modules/mysql2/lib/connection.js:85:12)
at PacketParser.executeStart (/home/abroadinquiry/server/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket. (/home/abroadinquiry/server/node_modules/mysql2/lib/connection.js:92:25)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23)
Emitted 'error' event on Connection instance at:
at Connection.protocolError (/home/abroadinquiry/server/node_modules/mysql2/lib/connection.js:397:10)
at Connection.handlePacket (/home/abroadinquiry/server/node_modules/mysql2/lib/connection.js:445:14)
[... lines matching original stack trace ...]
at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
fatal: true,
code: 4031

error er_con_count_error too many connections express mysql

I am programming in angular and create an api server in express, I have a little problem when I have been programming and making requests in the API for hours. What happens is what arrives as a maximum number of requests and throws me an error.
The operation is fine nothing fails me, it is only after a while that I get that error and for that reason the database is disconnected and my frontend in angular works.
After a while the server throws this error at me
(node:10356) UnhandledPromiseRejectionWarning: Error: ER_CON_COUNT_ERROR: Too many connections
at Handshake.Sequence._packetToError (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Handshake.ErrorPacket (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\sequences\Handshake.js:123:18)
at Protocol._parsePacket (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Connection.js:88:28)
at Socket.<anonymous> (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Connection.js:526:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
--------------------
at Protocol._enqueue (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at PoolConnection.connect (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Connection.js:116:18)
at Pool.getConnection (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Pool.js:48:16)
at Pool.query (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Pool.js:202:8)
at Promise (C:\xampp\htdocs\sinapsisuao\server\node_modules\promise-mysql\lib\helper.js:26:45)
at Promise._execute (C:\xampp\htdocs\sinapsisuao\server\node_modules\bluebird\js\release\debuggability.js:384:9)
at Promise._resolveFromExecutor (C:\xampp\htdocs\sinapsisuao\server\node_modules\bluebird\js\release\promise.js:518:18)
at new Promise (C:\xampp\htdocs\sinapsisuao\server\node_modules\bluebird\js\release\promise.js:103:10)
at Pool.promiseCallback (C:\xampp\htdocs\sinapsisuao\server\node_modules\promise-mysql\lib\helper.js:8:16)
at pool.query (C:\xampp\htdocs\sinapsisuao\server\node_modules\promise-mysql\lib\pool.js:57:32)
at C:\xampp\htdocs\sinapsisuao\server\build\controllers\facilitadorController.js:16:42
at Generator.next (<anonymous>)
at fulfilled (C:\xampp\htdocs\sinapsisuao\server\build\controllers\facilitadorController.js:5:58)
(node:10356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
GET /api/facilitadores - - ms - -
OPTIONS /api/facilitadores 204 0.126 ms - 0
(node:10356) UnhandledPromiseRejectionWarning: Error: ER_CON_COUNT_ERROR: Too many connections
at Handshake.Sequence._packetToError (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Handshake.ErrorPacket (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\sequences\Handshake.js:123:18)
at Protocol._parsePacket (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Connection.js:88:28)
at Socket.<anonymous> (C:\xampp\htdocs\sinapsisuao\server\node_modules\mysql\lib\Connection.js:526:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
My code database is this:
import { createPool } from "promise-mysql";
import keys from "./keys";
export async function connect(){
const connection = createPool(keys.database);
return connection;
}
And my index is:
import express, { Application } from "express";
import morgan from 'morgan';
import cors from 'cors';
import indexRoutes from './routes/indexRoutes';
import usersRoutes from './routes/users.Routes';
import emprendedorRoutes from './routes/emprendedor.Routes';
import facilitadorRoutes from "./routes/facilitador.Routes";
import consultoriaRoutes from "./routes/consultoria.Route";
import emprendimientoRoutes from "./routes/emprendimiento.Routes";
import calendarioRoutes from "./routes/calendar.Route";
import atencionRoutes from "./routes/atencion.Route";
class Server {
public app: Application;
constructor(){
this.app = express();
this.config();
this.routes();
}
//configuracion
config(): void{
this.app.set('port', process.env.PORT || 3000);
this.app.use(morgan("dev"));
this.app.use(cors());
this.app.use(express.json());
this.app.use(express.urlencoded({extended: false}));
}
//rutas
routes(): void {
this.app.use('/',indexRoutes);
this.app.use('/api/users',usersRoutes);
this.app.use('/api/emprendedores', emprendedorRoutes);
this.app.use('/api/facilitadores', facilitadorRoutes);
this.app.use('/api/consultorias', consultoriaRoutes );
this.app.use('/api/emprendimientos', emprendimientoRoutes );
this.app.use('/api/calendar', calendarioRoutes);
this.app.use('/api/atencion', atencionRoutes)
}
//inicia servidor
start(): void{
this.app.listen(this.app.get('port'), ()=>{
console.log('Server on port', this.app.get('port'));
console.log("Conectados a la BD");
});
}
}
const server = new Server();
server.start();
Someone, who can help me with this problem, only appears when I have been programming for a while.
max_connect_errors defaults to 100. When you are using connection pools this means a number of sparatic errors can quickly add up to 64 resulting in the error experiences.
Solution part 1: remove the connection pooling. Simple per connection is ok.
Solution part 2: increase max_connect_errors to its documented maximium
Solution part 3: try to identify some of the errors that occur and see if they are programmatic mistakes or transient network connection problems.

How to make AWS S3 request retryable?

Sometimes when I download multiple files from S3 bucket using node sdk, the request will timeout for one of the downloads. I would like for the request to just retry to attempt to download again.
The json error response says retryable: false.
Is there a way I can configure it to be true?
Here is the error:
{ TimeoutError: Connection timed out after 480000ms
at ClientRequest.<anonymous> (node_modules/aws-sdk/lib/http/node.js:83:34)
at Object.onceWrapper (events.js:272:13)
at ClientRequest.emit (events.js:180:13)
at ClientRequest.emit (domain.js:421:20)
at TLSSocket.emitTimeout (_http_client.js:703:34)
at Object.onceWrapper (events.js:272:13)
at TLSSocket.emit (events.js:180:13)
at TLSSocket.emit (domain.js:421:20)
at TLSSocket.Socket._onTimeout (net.js:396:8)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5)
message: 'Connection timed out after 480000ms',
code: 'TimeoutError',
time: 2019-04-01T17:58:41.010Z,
region: 'us-west-2',
hostname: 'bucket-name',
retryable: false,
statusCode: 200,
retryDelay: 129.76727762396757 }
I am not sure of how you are using the resources as you didn't share your code, but this might help you.
// setting retries
var s3 = new AWS.S3({apiVersion: '2006-03-01', maxRetries:10});
S3 sdk documentation - maxRetries

DeprecationWarning: Calling an asynchronous function without callback is deprecated, where to find it?

So i keep getting this error which redirects me to node_modules and I'm not sure if I would check there.. Everything was fine until node.js version update yesterday.
The error with trace:
node --trace-deprecation tradeBot.js
(node:10062) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
at maybeCallback (fs.js:95:42)
at Object.fs.writeFile (fs.js:1191:14)
at FileStorage.saveFile.FileStorage.writeFile (/****/node_modules/file-manager/index.js:68:5)
at SteamUser._handlers.(anonymous function) (/****/node_modules/steam-user/components/logon.js:252:18)
at SteamUser._handleMessage (/****/node_modules/steam-user/components/messages.js:200:29)
at emitThree (events.js:116:13)
at CMClient.emit (events.js:194:7)
at CMClient._netMsgReceived (/****/node_modules/steam-client/lib/cm_client.js:278:8)
at CMClient.handlers.(anonymous function) (/****/node_modules/steam-client/lib/cm_client.js:386:8)
at CMClient._netMsgReceived (/****/node_modules/steam-client/lib/cm_client.js:260:24)
at emitOne (events.js:96:13)
at TCPConnection.emit (events.js:188:7)
at TCPConnection._readPacket (/****/node_modules/steam-client/lib/tcp_connection.js:73:7)
at emitNone (events.js:86:13)
at TCPConnection.emit (events.js:185:7)
at emitReadable_ (_stream_readable.js:432:10)

Categories