how to resolve refreshbrokermetadata failed issue in node? - node.js

Getting below issue while integrating kafka with node after certain time of application get started in node server.
There is not any log in kafka server as well as it is up and running.
/app/node_modules/async/dist/async.js:5329
return callback.apply(null, arguments);
^
NestedError: refreshBrokerMetadata failed
at /app/node_modules/kafka-node/lib/kafkaClient.js:378:35
at /app/node_modules/async/dist/async.js:473:16
at next (/app/node_modules/async/dist/async.js:5329:29)
at /app/node_modules/async/dist/async.js:969:16
at KafkaClient.getAvailableBroker (/app/node_modules/kafka-node/lib/kafkaClient.js:330:12)
at /app/node_modules/kafka-node/lib/kafkaClient.js:373:23
at nextTask (/app/node_modules/async/dist/async.js:5324:14)
at Object.waterfall (/app/node_modules/async/dist/async.js:5334:5)
at KafkaClient.refreshBrokerMetadata (/app/node_modules/kafka-node/lib/kafkaClient.js:372:9)
at Immediate._onImmediate (/app/node_modules/kafka-node/lib/kafkaClient.js:782:20)
Caused By: Error: Unable to find available brokers to try
at KafkaClient.getAvailableBroker (/app/node_modules/kafka-node/lib/kafkaClient.js:330:21)
at /app/node_modules/kafka-node/lib/kafkaClient.js:373:23
at nextTask (/app/node_modules/async/dist/async.js:5324:14)
at Object.waterfall (/app/node_modules/async/dist/async.js:5334:5)
at KafkaClient.refreshBrokerMetadata (/app/node_modules/kafka-node/lib/kafkaClient.js:372:9)
at Immediate._onImmediate (/app/node_modules/kafka-node/lib/kafkaClient.js:782:20)
at processImmediate (internal/timers.js:461:21)
error Command failed with exit code 1.

Related

Redis connection to x.x.x.x:6379 failed - write ECONNRESET. NodeJS GCP Standard Environment

The redis get calls sometimes fails with the following error. Once this happens, as a follow through, many of the requests fail/timeout intermittently with a 502 status.
{ Error: Redis connection to X.X.X.X:6379 failed - write ECONNRESET
at afterWriteDispatched (internal/stream_base_commons.js:78:25)
at writeGeneric (internal/stream_base_commons.js:73:3)
at Socket._writeGeneric (net.js:714:5)
at Socket._write (net.js:726:8)
at doWrite (_stream_writable.js:415:12)
at writeOrBuffer (_stream_writable.js:399:5)
at Socket.Writable.write (_stream_writable.js:299:11)
at RedisClient.write (/workspace/node_modules/redis/index.js:949:43)
at RedisClient.internal_send_command (/workspace/node_modules/redis/index.js:885:14)
at RedisClient.internal_send_command_trace [as internal_send_command] (/workspace/node_modules/#google-cloud/trace-agent/build/src/plugins/plugin-redis.js:91:50)
at RedisClient.get (/workspace/node_modules/redis/lib/commands.js:46:25)
at Promise (internal/util.js:274:30)
at new Promise (<anonymous>)
at RedisClient.get (internal/util.js:273:12)
at ConversationQueueServices.startTimeoutToClearQueueForVisitor (/workspace/ls/Services/ConversationQueueServices.js:306:57)
at PeoplesService.onVisitorSubscriberLeft (/workspace/ls/Services/PeoplesService.js:51:31)
at app.post (/workspace/app.js:196:27)
at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
at next (/workspace/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/workspace/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/workspace/node_modules/express/lib/router/layer.js:95:5)
at /workspace/node_modules/express/lib/router/index.js:281:22 errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'write' }
From the looks of it, ECONNRESET indicates the connection is closed by redis instance. There is no surge of traffic of any sort. cpu, memory and number of connections are as usual.
Will moving to updated redis npm client may help? Currently using 3.0.2 redis client version
Any help is much appreciated. Thanks in advance.
ECONNRESET error is thrown usually when the other end of the connection which could be TCP connected node that is communicating with the server or calling out and the socket timeout results in no response received which results in the sender closing it with the timeout exception handling type.
You can try to add retries or increase the timeout for the redis connection configurations.
Try running through this tutorial which might be helpful for troubleshooting the Redis Setup.
Please check a similar example with details node-js-best-practice-exception-handling.

Azure - nodejs serverless function throwing error Error: 13 INTERNAL: Failed to parse server response

I am getting the below expeception, my node serverless function is throwing exception however many time it works correctly, when I check failed request, these exceptions are found.
Exception while executing function: Functions.createParticipantUserEntry node exited with code 1
at Object.module.exports.exports.createStatusError (/azure-functions-host/workers/node/worker-bundle.js:980:15),
details: 'Failed to parse server response',LanguageWorkerConsoleLog[error]
Worker 78afd559-7c19-4b0d-9a60-9a3039049fe2 uncaught exception: Error: Error: 13 INTERNAL: Failed to parse server response
at ClientDuplexStream.<anonymous> (/azure-functions-host/workers/node/worker-bundle.js:18483:19)
at ClientDuplexStream.emit (events.js:400:28)
at ClientDuplexStream._emitStatusIfDone (/azure-functions-host/workers/node/worker-bundle.js:7691:12)
at ClientDuplexStream._receiveStatus (/azure-functions-host/workers/node/worker-bundle.js:7668:8)
at Object.onReceiveStatus (/azure-functions-host/workers/node/worker-bundle.js:23065:15)
at InterceptingListener.module.exports.InterceptingListener._callNext (/azure-functions-host/workers/node/worker-bundle.js:22322:42)
at InterceptingListener.module.exports.InterceptingListener.onReceiveStatus (/azure-functions-host/workers/node/worker-bundle.js:22372:8)
at /azure-functions-host/workers/node/worker-bundle.js:22881:18
This issue is different than Error: 14, this one is Error 13 which is related to the response while Error 14 is related to connection to the azure portal from VS Code.

how to push data into mongodb using sparkfun phant?

I am new to phant and i cannot find a suitable documentation on phant using mongodb. because i have lots of data and it memory overflow occurs. and finally i fell into following error:
HTTP output: { [Error: EMFILE, open 'phant_streams/4d16/83403f7611e5810d57f88174fbef/stream.csv']
errno: -24,
code: 'EMFILE',
path: 'phant_streams/4d16/83403f7611e5810d57f88174fbef/stream.csv' }
events.js:87
throw Error('Uncaught, unspecified "error" event.');
^
Error: Uncaught, unspecified "error" event.
at Error (native)
at Function.emit (events.js:87:13)
at Function.<anonymous> (/usr/lib/node_modules/phant/node_modules/phant-manager-http/index.js:237:12)
at PhantMeta.<anonymous> (/usr/lib/node_modules/phant/node_modules/phant-meta-nedb/lib/phant-meta-nedb.js:243:14)
at callback (/usr/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/executor.js:30:17)
at /usr/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/datastore.js:536:25
at /usr/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/persistence.js:201:12
at fs.js:1077:21
at FSReqWrap.oncomplete (fs.js:95:15)
except this sometimes following error also occurs:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
thats why i want to use mongodb to prevent this error. i searched about this and finally found sparckfun library for mongodb:
https://github.com/sparkfun/phant-stream-mongodb
i installed this but nothing happened as data still not string into mongo.
so, How will i store phant data into mongodb ?
I had the same problem, specifically trying to deploy my own Phant instance on Heroku (since I wanted to circumvent Sparkfun's 50Mb limit). After some dabbling with versions of the mongodb and mongoose libraries, I successfully forked and modified their repository so that you can either run it locally or directly deploy on heroku (just make sure you provision a MongoLab add-on). Check out my fork here: https://github.com/davidlago/phant
Hope this helps!

SailsJs Invalid module error

After I installed lodash or async plug-ins,
Console shows those error messages when I launch sails.js.
but I don't know what cause those error messages.
I need to solve this problem. please anyone help me.
error: A hook (`userconfig`) failed to load!
error: Error: Invalid module:[object Object]
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:83:15
at forOwn (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:2105:15)
at Function.forEach (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:3302:9)
at buildDictionary (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:74:4)
at Function.module.exports.aggregate (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles [as 0] (/Users/johndo/github/sails/testProject/node_modules/sails/lib/hooks/moduleloader/index.js:164:27)
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:459:38
at Array.forEach (native)
at _each (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:32:24)
at Object.async.auto (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:430:9) [Error: Invalid module:[object Object]]
error: Error: Invalid module:[object Object]
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:83:15
at forOwn (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:2105:15)
at Function.forEach (/Users/johndo/github/sails/testProject/node_modules/lodash/dist/lodash.js:3302:9)
at buildDictionary (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:74:4)
at Function.module.exports.aggregate (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles [as 0] (/Users/johndo/github/sails/testProject/node_modules/sails/lib/hooks/moduleloader/index.js:164:27)
at /Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:459:38
at Array.forEach (native)
at _each (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:32:24)
at Object.async.auto (/Users/johndo/github/sails/testProject/node_modules/sails/node_modules/async/lib/async.js:430:9) [Error: Invalid module:[object Object]]
It looks like it's experiencing an error while parsing your configuration files. Try rolling back your changes.
Also, lodash and async come as globals in sails, so you don't need to install them. Just go to config/globals and uncomment _(lodash). That might fix your problem, as maybe sails is having a conflict between its installed version and yours.

Node.js and Sphinx concurrent connection issue on Server

I have been using Sphinx Technology for site and implemented in php and Node.js. Using php and Sphinx, so far i didn't get any issues. But with Node.js and Sphinx, i got the following issues rapidly,
1. Error: Error: Connection is opening in OnConnect
at Socket.<anonymous> (/usr/local/lib/node_modules/limestone/limestone.js:217:26)
at Socket.emit (events.js:64:17)
at Object.afterConnect [as oncomplete] (net.js:614:10)
2. node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: write EPIPE
at errnoException (net.js:640:11)
at Object.afterWrite [as oncomplete] (net.js:478:18)
I have been using limestone node.js module as middleware between Node.js and Sphinx server. My assumption is that above error is occured due to the concurrent connection request to Sphinx. If so, then how to avoid the concurrent sphinx request.
Please suggest on the same.
you can try using sphinxql via one of mysql libraries available for sphinx.

Resources