Code Monkey home page Code Monkey logo

Comments (17)

ronag avatar ronag commented on July 20, 2024 1

Cool. I'm closing this issue.

from node-http2-proxy.

ronag avatar ronag commented on July 20, 2024

Not sure if this is related to this library. Can you please provide a full example

from node-http2-proxy.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

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.

ronag avatar ronag commented on July 20, 2024

I just tried your example and it works fine.

from node-http2-proxy.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

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.

ronag avatar ronag commented on July 20, 2024

Seems like a common problem, request/request#210

from node-http2-proxy.

ronag avatar ronag commented on July 20, 2024

Do you have the same problem with Node 14?

from node-http2-proxy.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

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.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

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.

ronag avatar ronag commented on July 20, 2024

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.

ronag avatar ronag commented on July 20, 2024

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.

ronag avatar ronag commented on July 20, 2024

I think you are probably hitting the maximum number of concurrent sockets on your platform.

from node-http2-proxy.

ronag avatar ronag commented on July 20, 2024

Also, did you try https://docs.oracle.com/cd/E26180_01/Search.94/ATGSearchAdmin/html/s1207adjustingtcpsettingsforheavyload01.html?

from node-http2-proxy.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

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.

ronag avatar ronag commented on July 20, 2024

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.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

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.

hanspeter1 avatar hanspeter1 commented on July 20, 2024

THX

from node-http2-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.