I would like to enable the use of the connection pool through http.Agentand https.Agentin my node-http-proxy application . To do this, I created a secure agent, for example:
const secureAgent = new https.secureAgent({ keepAlive: true });
(I briefly explained the optional http agent for short.)
I am creating a proxy server as such:
const proxy = httpProxy.createProxyServer({});
Finally, I proxy the request inside Connect middleware like this:
proxy.web(req, res {
agent: isSecure ? secureAgent : agent,
target: ...,
secure: false,
});
This seems to work for most queries, but every few minutes I see an error that looks like this:
{
"message": "Parse Error",
"stack": "Error: Parse Error\n at TLSSocket.socketOnData (_http_client.js:411:20)\n at emitOne (events.js:96:13)\n at TLSSocket.emit (events.js:191:7)\n at readableAddChunk (_stream_readable.js:178:18)\n at TLSSocket.Readable.push (_stream_readable.js:136:10)\n at TLSWrap.onread (net.js:560:20)",
"bytesParsed": 215,
"code": "HPE_INVALID_CONSTANT",
"__error_callsites": [
{},
{},
{},
{},
{},
{}
],
"level": "error",
"timestamp": "2017-04-18T17:34:09.735Z"
}
From some cursory reading, it seems that it HPE_INVALID_CONSTANTappears when the answer is distorted. However, these responses are excellent prior to administration of the protected agent.
Does anyone know what is going on here or how can I fix it?
. Node v7.9.0 Docker FROM node:7.9. HEAD - - .