nodejs, http, legacy servers, and "HPE_UNEXPECTED_CONTENT_LENGTH" - node.js

Running a simple http request in nodejs for web crawling purposes.
Unfortunately, one website we're trying to crawl is configured such that it has the Content-Length header twice.
This is throwing an error on nodejs:
Error: Parse Error
at Error (native)
at Socket.socketOnData (_http_client.js:363:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20) bytesParsed: 239, code:'HPE_UNEXPECTED_CONTENT_LENGTH' },
isOperational: true,
bytesParsed: 239,
code: 'HPE_UNEXPECTED_CONTENT_LENGTH'
I'm trying to find a workaround that doesn't involve downgrading my nodejs server... Any ideas?

Related

Mongoose deployment issues

I am trying to connect to Mongolab through the Expressjs. But when I run ,I am getting failed to connect to the server
Error Message :
MongoError: failed to connect to server [ds033066.mlab.com:33066] on first con
nect [MongoError: connect ETIMEDOUT 54.80.215.206:33066]
at Pool.<anonymous> (C:\Users\rkishore\Documents\node\node_modules\mongoose\
node_modules\mongodb-core\lib\topologies\server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (C:\Users\rkishore\Documents\node\node_modules\mon
goose\node_modules\mongodb-core\lib\connection\pool.js:280:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (C:\Users\rkishore\Documents\node\node_modules\mongoos
e\node_modules\mongodb-core\lib\connection\connection.js:177:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1277:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
name: 'MongoError',
message: 'failed to connect to server [ds033066.mlab.com:33066] on first conne
ct [MongoError: connect ETIMEDOUT 54.80.215.206:33066]'
Any Help/Suggestion greatly appreciated.

React Twitter OAuth Callback Status Code 401

Wanted to test Twitter OAuth callback with my React app on localhost.
Saw that you could use http://127.0.0.1:8000 in the Twitter App Console for both Website and Callback URL fields for it to work with localhost.
const twitterStream = new Twitter(twitterConfig.TWITTER_CONFIG);
I am using the twitter npm and getting the following 401 status code error --
Error: Status Code: 401
at Request.<anonymous> (/Users/me/Projects/project-name/node_modules/twitter/lib/twitter.js:277:28)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestResponse (/Users/me/Projects/pproject-name/node_modules/request/request.js:986:10)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:474:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
at TLSSocket.socketOnData (_http_client.js:363:20)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
at TLSWrap.onread (net.js:548:20)
Appreciate the help.
You need to set http://127.0.0.1:8000/auth/twitter/callback as the callback URL in application settings back on Twitter.

API Pod failed to connect to mongo pod in the same kubernetes cluster

I was running a nodejs api as a pod on a google compute engine managed by kubernetes. The API was connecting to database well but then it failed suddenly showing this error:
listening to http server on 0.0.0.0:8080...
events.js:160
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: getaddrinfo ENOTFOUND mongo mongo:27017]
at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:274:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:177:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at connectErrorNT (net.js:1021:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
I tried to restart the prods, to delete and re-create containers but no success?
this is how I connect to database:
mongoose.connect(process.env.MONGO_DEV_URL || process.env.MONGODB_URI || 'mongodb://mongo:27017:yaxiDb/yaxiDb', { useMongoClient: true });
How can I debug this, where could be the problem?
I just found the solution, the order of creating services matters. I've deleted all services that use that database and re-create them:
kubectl delete -f containers/backend/
kubectl create -f containers/backend/

Firebase: ApiError: Unauthorized Error

I have firebase cloud function working, but today I am seeing following error:
Please suggest what is wrong with firebase functions.
ApiError: Unauthorized
at new util.ApiError (/user_code/node_modules/#google-cloud/storage/node_modules/#google-cloud/common/src/util.js:107:10)
at Object.parseHttpRespMessage (/user_code/node_modules/#google-cloud/storage/node_modules/#google-cloud/common/src/util.js:149:33)
at Object.handleResp (/user_code/node_modules/#google-cloud/storage/node_modules/#google-cloud/common/src/util.js:124:18)
at Duplexify.<anonymous> (/user_code/node_modules/#google-cloud/storage/src/file.js:711:21)
at emitOne (events.js:96:13)
at Duplexify.emit (events.js:188:7)
at emitOne (events.js:96:13)
at DestroyableTransform.emit (events.js:188:7)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
Note: I know they were migrating to newer nodejs, Is it because of it?
Solution here solved the problem:
https://stackoverflow.com/a/43106877/1590595
I am keeping an eye, if it occurs, I will update the answer.

cannot connect loopback with mongodb

i'm trying to execute the commande "slc run" to access to API loopback but ther's a problem with mongodb even if i run mongod it display this error :
MongoError: Authentication failed.
at Function.MongoError.create (C:\Users\abdessamad\ingeweb_workspace\roll-lo
opback\node_modules\mongodb-core\lib\error.js:31:11)
at C:\Users\abdessamad\ingeweb_workspace\roll-loopback\node_modules\mongodb-
core\lib\connection\pool.js:483:72
at authenticateStragglers (C:\Users\abdessamad\ingeweb_workspace\roll-loopba
ck\node_modules\mongodb-core\lib\connection\pool.js:429:16)
at Connection.messageHandler (C:\Users\abdessamad\ingeweb_workspace\roll-loo
pback\node_modules\mongodb-core\lib\connection\pool.js:463:5)
at Socket.<anonymous> (C:\Users\abdessamad\ingeweb_workspace\roll-loopback\n
ode_modules\mongodb-core\lib\connection\connection.js:319:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:189:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:551:20)

Resources