NestedError: topic/partition change check failed - apache-kafka

Suddenly I got an issue in running process of apache kafka consumer group.
Anyone please share your thoughts on why this issue happens.
NestedError: topic/partition change check failed
at _checkTopicPartitionChange (<system-path>/node_modules/kafka-node/lib/consumerGroup.js:295:37)
at client.loadMetadataForTopics (<system-path>/node_modules/kafka-node/lib/consumerGroup.js:323:14)
at async.series (<system-path>/node_modules/kafka-node/lib/kafkaClient.js:919:7)
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:3888:9
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:473:16
at iterateeCallback (<system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:988:17)
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:969:16
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:3885:13
at Timeout.setTimeout [as _onTimeout] (<system-path>/node_modules/kafka-node/lib/kafkaClient.js:491:5)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
Caused By: TimeoutError: Request timed out after 30000ms
at new TimeoutError (<system-path>/node_modules/kafka-node/lib/errors/TimeoutError.js:6:9)
at Timeout.setTimeout [as _onTimeout] (<system-path>/node_modules/kafka-node/lib/kafkaClient.js:491:14)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
(node:12516) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Any help would be appreciable.

Related

TIMEOUT WHILE CONNECTING TO SERVER

When I use Wi-Fi to upload code through VS Code, it shows the following error. But if I use mobile network, it works.
[error] Error: Timeout while connecting to server
at Timeout._onTimeout (c:\Users\faraz\.vscode\extensions\liximomo.sftp-1.12.9\dist\extension.js:70:109790)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)

mongo-express does not connect to mongodb

i have installed mongodb and i am able to connect via shell, now i am trying to install mongo-express, the installation was successful, i copied config.default.js file in config.js but it can't connect to mongo. As can be seen from the error it cannot retrieve the hostname
(node:3085) 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)
Could not connect to database at index "0"
(node:3085) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [undefined:27017] on first connect [Error: getaddrinfo ENOTFOUND undefined
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) {
name: 'MongoNetworkError'
}]
at Pool.<anonymous> (/Users/name/.config/yarn/global/node_modules/mongodb/lib/core/topologies/server.js:438:11)
at Pool.emit (events.js:315:20)
at /Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/pool.js:562:14
at /Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/pool.js:995:11
at /Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/connect.js:32:7
at callback (/Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/connect.js:280:5)
at Socket.<anonymous> (/Users/name/.config/yarn/global/node_modules/mongodb/lib/core/connection/connect.js:310:7)
at Object.onceWrapper (events.js:422:26)
at Socket.emit (events.js:315:20)
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)
(node:3085) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3085) [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.
I had the same error.
Forcing the connection URL fixed it for me :
mongo-express --url "mongodb://localhost:27017" --admin
(--admin option allows to list all databases)

Can't connect to mongodb cloud

I'm working on a web application with node.js and using Mongodb for database. everything is cool when I run my app in localhost. but when I run it in a shared host it gives an error which looks like its Mongoose connection problem.
here is my code:
const uri = 'mongodb://****:****#iranroboticacademy-bdziw.mongodb.net/test';
mongoose.connect(uri,{ useNewUrlParser: true });
mongoose.connection.once('open', function(){
console.log('DataBase is connected. ');
}).on('error', function(error){
console.log('Connection error:', error);
});
and here is the erro that I get when I run the app in host:
Connection error: { MongoNetworkError: failed to connect to server [iranroboticacademy-shard-00-00-bdziw.mongodb.net:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 3.226.212.92:27017]
at Pool.<anonymous> (/home/iranrob1/public_html/node_modules/mongodb/lib/core/topologies/server.js:433:11)
at Pool.emit (events.js:182:13)
at createConnection (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/pool.js:577:14)
at connect (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/pool.js:1021:9)
at makeConnection (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/connect.js:31:7)
at callback (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/connect.js:247:5)
at TLSSocket.err (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/connect.js:276:7)
at Object.onceWrapper (events.js:273:13)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {} }
(node:6409) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [iranroboticacademy-shard-00-00-bdziw.mongodb.net:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 3.226.212.92:27017]
at Pool.<anonymous> (/home/iranrob1/public_html/node_modules/mongodb/lib/core/topologies/server.js:433:11)
at Pool.emit (events.js:182:13)
at createConnection (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/pool.js:577:14)
at connect (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/pool.js:1021:9)
at makeConnection (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/connect.js:31:7)
at callback (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/connect.js:247:5)
at TLSSocket.err (/home/iranrob1/public_html/node_modules/mongodb/lib/core/connection/connect.js:276:7)
at Object.onceWrapper (events.js:273:13)
at TLSSocket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:6409) 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:6409) [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.
Sure you can use the free tier of MongoDB Cloud.
It’s actually much easier to mantain than the hosted version as you have visually all under control, automatic backups etc.
https://mongodb.com
I have asked my host provider in a ticket and they said it doesn’t support mongodb. I have written everything with mongodb database in my application and I really can’t change it into other things. I need to use it in this host. Is there anyone who has a solution for this?!
try to use 'connect to your aplication', copy the then change the

unable to access json server

I created a mock json server and trying to open in browser ,landing in the following error:
events.js:167
throw er; // Unhandled 'error' event
^
Error: listen EACCES 127.0.0.1:8000
at Server.setupListenHandle [as _listen2] (net.js:1313:19)
at listenInCluster (net.js:1378:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1491:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:55:10)
Emitted 'error' event at:
at emitErrorNT (net.js:1357:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
Please help.

Invalid permission from Lambda to MongoDB in EC2

I have created a Lambda Function which intends to connect to MongoDB running on EC2.
I have followed some tutorials and guaranteed that:
Lambda and EC2 run in the same VPC
Lambda has configured EC2's subnet
Lambda has its own security group my-lambda-sg
Lambda's security group is allowed in EC2's security group inbounds rules for MongoDB's port as a "Custom TCP Rule"
Lambda's role has assigned permission AWSLambdaVPCAccessExecutionRole
However, I am stil unable to connect from the lambda to the MongoDB in EC2. When I run a Test in the Lambda I get:
START RequestId: f0869292-5207-11e8-85d2-cba0eb99208c Version: $LATEST
2018-05-07T15:04:29.117Z 567951c4-5207-11e8-ba43-0314179d2bf5 { MongoNetworkError: failed to connect to server [IP:port] on first connect [MongoNetworkError: connection 0 to IP:port timed out]
at Pool.<anonymous> (/var/task/node_modules/mongodb-core/lib/topologies/server.js:503:11)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection.<anonymous> (/var/task/node_modules/mongodb-core/lib/connection/pool.js:326:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket.<anonymous> (/var/task/node_modules/mongodb-core/lib/connection/connection.js:256:10)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:420:8)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
name: 'MongoNetworkError',
message: 'failed to connect to server [IP:port] on first connect [MongoNetworkError: connection 0 to IP:port timed out]' }
END RequestId: f0869292-5207-11e8-85d2-cba0eb99208c
From API Gateway I get
You do not have permission to perform this action
And from the browser I get:
{"message": "Endpoint request timed out"}
Other Lambda's not accessing EC2 are working fine.
Any idea what could I be missing?
I found the answer. All requisites above are ok. I just needed to use the internal IP of the EC2 instead the external one in the MongoDB URL connection, to be considered a call within the VPC, as I found here AWS Lambda unable to access EC2 port within the same VPC