I'm setting up an api application based on NodeJS and the ORM Sequelize. Everything work fine on my local computer (Windows), but when I want to install this app on a AWS EC2 Linux Instance, I'm encountering this error at the launch of the app :
internal/buffer.js:53
throw new ERR_OUT_OF_RANGE(type || 'offset',
^
RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 5. Received 9
at boundsError (internal/buffer.js:53:9)
at Uint8Array.readUInt32LE (internal/buffer.js:109:5)
at Packet.readInt32 (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/packets/packet.js:103:24)
at Function.fromPacket (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/packets/handshake.js:59:32)
at ClientHandshake.handshakeInit (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/commands/client_handshake.js:92:40)
at ClientHandshake.execute (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/commands/command.js:39:22)
at Connection.handlePacket (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/connection.js:449:32)
at PacketParser.Connection.packetParser.p [as onPacket] (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/connection.js:72:12)
at PacketParser.executeStart (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/packet_parser.js:75:16)
at Socket.Connection.stream.on.data (/home/ec2-user/live/CodexAvatarAPI/node_modules/mysql2/lib/connection.js:79:25)
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)
I've done some research but found nothing useful for now. To my understanding (i'm a beginner with node), the problem seems to be more in the mysql2 component than in the core of NodeJS itself, but I'm not sure where to search exactly.
This error happen juste before synchronizing the database structure with what has been defined in the code. Normally I have to see database update at this point.
Related
I'm just starting with Node.js and I'm following this tutorial https://dev.to/glaucia86/developing-a-crud-node-js-application-with-postgresql-4c9o
when setting .env file as suggested
DATABASE_URL=postgres://{db_username}:{db_password}#{host}:{port}/{db_name}
so
DATABASE_URL=postgres://vinnytwice:pass#localhost:5432/fixit
I start the server with npm start command when using Postman to send a Post request I get they error in console:
vinnytwice#Vinnys-iMac fixit_server_node % npm start
> fixit_server_node#1.0.0 start
> node server.js
App executing to port 3000
error: database "vinnytwice" does not exist
at Parser.parseErrorMessage (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:369:20)
at addChunk (node:internal/streams/readable:313:12)
at readableAddChunk (node:internal/streams/readable:288:9)
at Socket.Readable.push (node:internal/streams/readable:227:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
What am I doing wrong ?
Many thanks.
Finally found the problem, the .env file wasn't at the root of the project.
I am following this tutorial to install a Rocket.chat server in CentOS:
https://hostpresto.com/community/tutorials/how-to-install-rocket-chat-server-on-centos-7/
I am new to mongodb and node.js so I am not very familiar with how all this works
At the moment I am looking for something simple that just works
When I reach the step where it says to execute
node main.js
I get the following error:
[username#localhost Rocket.chat]$ node main.js
/opt/Rocket.chat/programs/server/node_modules/fibers/future.js:313
throw(ex);
^
MongoError: not master and slaveOk=false
at Connection.<anonymous> (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:450:61)
at Connection.emit (events.js:310:20)
at processMessage (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:384:10)
at Socket.<anonymous> (/opt/Rocket.chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:553:15)
at Socket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
ok: 0,
errmsg: 'not master and slaveOk=false',
code: 13435,
codeName: 'NotMasterNoSlaveOk',
[Symbol(mongoErrorContextSymbol)]: {}
}
The tutorial says I should be able to see the Rocket.chat web interface if I go to https://yourdomain.com:3000 but I get an unable to connect page, which I suppose is due to the error above
The tutorial also says node main.js is to check if MongoDB is running or not. I can see that MongoDb service is running by executing
systemctl status mongod
so this error seems to be caused by something else.
How do I find out what is causing this error? Or are there any mistakes in this tutorial? I have found other tutorials regarding installing Rocket.chat in CentOS but most of them use nginx as hte web server while I need to use Apache.
I have a project that I recently put in a production server (not live, but different from my development environment). I configured a mongoDB server with a password authentication.
When I start my Nodejs Application, my usual code retrieve correctly my mongoDB server, returning a client.db object successfully.
But I also have an error popping-in. Something that is not called inside my Nodejs application apparently.
[ERROR] { MongoError: command createIndexes requires authentication
at Connection.<anonymous> (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/pool.js:460:61)
at Connection.emit (events.js:189:13)
at processMessage (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/connection.js:368:10)
at Socket.<anonymous> (/home/myaccount/myapp/node_modules/mongodb/lib/core/connection/connection.js:537:15)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
ok: 0,
errmsg: 'command createIndexes requires authentication',
code: 13,
codeName: 'Unauthorized',
name: 'MongoError',
[Symbol(mongoErrorContextSymbol)]: {} }
nothing in the error is pointing toward something I created, it's only about the mongodb npm library. It also giving this error even if a delete every MongoDB connexion related code (but not the mongodb library load).
Do you have any idea how to fix this ?
Okay it's my fault. I had another connexion point that I didn't changed from my express sessions. It's fixed now.
It's just weird the error didn't point toward that module..
I use the db-migrate to create the table. I have a sql statement.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
But I got a error.
[ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: could not load library "/Users/manlokwong/PostgreSQL/pg96/lib/postgresql/pgcrypto.so": dlopen(/Users/manlokwong/PostgreSQL/pg96/lib/postgresql/pgcrypto.so, 10): Library not loaded: /opt/pgbin-build/pgbin/shared/osx_64/lib/libcrypto.1.0.0.dylib
Referenced from: /Users/manlokwong/PostgreSQL/pg96/lib/postgresql/pgcrypto.so
Reason: image not found
at Connection.parseE (/usr/local/lib/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:553:11)
at Connection.parseMessage (/usr/local/lib/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:378:19)
at Socket. (/usr/local/lib/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:119:22)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:280:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onread (net.js:638:20)
The extension is unable to load an OpenSSL shared library at /opt/pgbin-build/pgbin/shared/osx_64/lib/libcrypto.1.0.0.dylib. Try fully reinstalling your PostgreSQL distribution or using one from Homebrew.
I have a Dedicated windows server, I am running my node express code on the server, but when an exception occurred like
error: remaining connection slots are reserved for non-replication superuser connections
at Connection.parseE (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:554:11)
at Connection.parseMessage (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:381:17)
at TLSSocket.<anonymous> (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:117:22)
at TLSSocket.emit (events.js:180:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
at TLSSocket.Readable.push (_stream_readable.js:213:10)
at TLSWrap.onread (net.js:578:20)
Emitted 'error' event at:
at Connection.<anonymous> (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\client.js:183:19)
at Connection.emit (events.js:180:13)
at TLSSocket.<anonymous> (C:\node\zykrrapi\prod\myapp\node_modules\pg\lib\connection.js:121:12)
at TLSSocket.emit (events.js:180:13)
[... lines matching original stack trace ...]
at TLSWrap.onread (net.js:578:20)
and another error like "too many connections to the user on database" error also occurs and stops the execution of the code. this makes a huge loss of the data for me.
I want to run the Node Js Code continuously and to start the execution again if it stopped unexpectedly.
I am running the code using command "npm start" in windows server...
I want this node code to run only on the windows dedicated server.