Comments (17)
Cool. I'm closing this issue.
from node-http2-proxy.
Not sure if this is related to this library. Can you please provide a full example
from node-http2-proxy.
Proxy
const Http = require("http");
const HttpProxy2 = require("http2-proxy");
const Cluster = require("cluster");
if (Cluster.isMaster) {
// Create worker
for (let core = 0; core < 8; core++) {
Cluster.fork();
}
} else {
let httpServer = Http.createServer();
httpServer.on("request", (req, res) => {
HttpProxy2.web(req, res, {
hostname: "localhost",
port: 8090
}, (err, req, res) => {
if (err) {
console.error(err)
}
res.end();
});
});
httpServer.listen(8080)
}
Proxy-Target
const http = require('http')
const port = 8090
const requestHandler = (request, response) => {
response.end('Hello Node.js Server!')
}
const server = http.createServer(requestHandler)
server.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})
Log
Error: connect EADDRINUSE 192.168.1.4:8090
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'EADDRINUSE',
code: 'EADDRINUSE',
syscall: 'connect',
address: '192.168.1.4',
port: 8090,
statusCode: 503,
connectedSocket: false,
reusedSocket: false
}
from node-http2-proxy.
I just tried your example and it works fine.
from node-http2-proxy.
The error does not appear for the first ~300 requests.
I used bombardier (https://github.com/codesenberg/bombardier) with bombardier -c 125 -n 10000000 http://localhost:8080 to generate requests.
System: Win10 / Node 12.18.1
from node-http2-proxy.
Seems like a common problem, request/request#210
from node-http2-proxy.
Do you have the same problem with Node 14?
from node-http2-proxy.
What version of node?
Node.js 12.18.1
Do you have the same problem with Node 14?
I will test
from node-http2-proxy.
Do you have the same problem with Node 14?
Same result ... :(
Error: connect EADDRINUSE 127.0.0.1:8090
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
errno: -4091,
code: 'EADDRINUSE',
syscall: 'connect',
address: '127.0.0.1',
port: 8090,
statusCode: 503,
connectedSocket: false,
reusedSocket: false
}
from node-http2-proxy.
I don't have bombardier nor does it seem to be on brew. Is there any other tool I can use to try and reproduce on Mac?
from node-http2-proxy.
Can you try with:
HttpProxy2.web(req, res, {
hostname: "localhost",
port: 8090,
onReq: options => http.request({ ...options, agent: false })
}, (err, req, res) => {
if (err) {
console.error(err)
}
res.end();
});
and also:
const agent = new http.Agent({ maxSockets: 128 });
...
HttpProxy2.web(req, res, {
hostname: "localhost",
port: 8090,
onReq: options => http.request({ ...options, agent })
}, (err, req, res) => {
if (err) {
console.error(err)
}
res.end();
});
from node-http2-proxy.
I think you are probably hitting the maximum number of concurrent sockets on your platform.
from node-http2-proxy.
Also, did you try https://docs.oracle.com/cd/E26180_01/Search.94/ATGSearchAdmin/html/s1207adjustingtcpsettingsforheavyload01.html?
from node-http2-proxy.
Can you try with:
HttpProxy2.web(req, res, { hostname: "localhost", port: 8090, onReq: options => http.request({ ...options, agent: false }) }, (err, req, res) => { if (err) { console.error(err) } res.end(); });and also:
const agent = new http.Agent({ maxSockets: 128 }); ... HttpProxy2.web(req, res, { hostname: "localhost", port: 8090, onReq: options => http.request({ ...options, agent }) }, (err, req, res) => { if (err) { console.error(err) } res.end(); });
Same error. Maybe it's a Windows bug
from node-http2-proxy.
I would try and open an issue on the nodejs issue tracker. Maybe you can get help there. I'm unsure how to help here. I don't have a Windows workstation unfortunately to continue digging.
from node-http2-proxy.
Now I know what the error was ... Windows!
Do not get an error on Ubuntu 20.04.
Next I'll try that (https://docs.oracle.com/cd/E26180_01/Search.94/ATGSearchAdmin/html/s1207adjustingtcpsettingsforheavyload01.html).
from node-http2-proxy.
THX
from node-http2-proxy.
Related Issues (20)
- Regex bug by choosing agent HOT 1
- onReq with finalhandler = Error HOT 5
- onReq param 2 (options) no longer the same thing in 5.x? HOT 2
- unknown difference between 4.2.15 and 5.0.13 HOT 7
- websockets don't proxy with 5.0.34 if the path isn't the same unless onReq is used HOT 2
- path: Target pathname. Defaults to req.originalUrl || req.url. HOT 1
- bug: onReq HOT 2
- Forwarding to unix socket HOT 4
- add typescript support HOT 3
- Add "ca", "key", "cert" options and "rejectUnauthorized" options for TLS-based HTTP servers using self-signed certificates. HOT 10
- Adding "http2 to http2" proxy functions for proxy servers is now much easier. HOT 8
- add undici support
- Possible wrong type for onReq HOT 3
- Issue with custom response streams handler HOT 2
- unable to proxy http2 request
- Connection upgrade support only websocket HOT 1
- secure: false HOT 2
- dear sir ,http2 bug & please update your doc
- websocket proxy not completing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-http2-proxy.