Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request "ping" does Not use Pool, spawning New Agent every interval #16

Closed
Opensourcecommunitydevelopment opened this issue Oct 24, 2016 · 1 comment
Labels

Comments

@Opensourcecommunitydevelopment
Copy link
Contributor

Opensourcecommunitydevelopment commented Oct 24, 2016

every Minute you see
Exceed pool maxSockets, creating a new Agent
this happens because the pinginterver

`setInterval(() => {
  let ping = forwardUrl + '?name=' + resolver.hostname;
  request(ping).pipe(devnull());
}, 60 * 1000);`

codepart

i fixed it with following:

setInterval(() => {     
      const http2Req = request({
            url: forwardUrl,
            qs: {
                name: resolver.hostname
                }
          }, (err, response, output) => {
            agentPool.release(http2Req.agent)
              })//.pipe(devnull());
}, 60 * 1000);

needed comment Out Pipe because

``
 { agent: undefined }
.\yyfrankyy\dns-over-http2\index.js:39
      if (tail.agent._spdyState.connection._spdyState.goaway) {
                    ^

TypeError: Cannot read property '_spdyState' of undefined
``

should we still use Pipe here, how?

On Start the first query is slow because delay of Agent Connection waiting created, so do it After init instantly To be ready. I removed Start delay with this:

const ping = function(){
    const http2Req = request({
        url: forwardUrl,
        qs: {
            name: resolver.hostname
            }
      }, (err, response, output) => {
        agentPool.release(http2Req.agent)
          })//.pipe(devnull());
    }
    setInterval(function(){
        ping()
    }, 60 * 1000)
    ping()

Run once started and every Minute As used To before. Opens a ready To use Agent directly. Check Benefit by Compare Response Milliseconds of first query ;-)

@yyfrankyy
Copy link
Owner

yyfrankyy commented Oct 25, 2016

maybe we don't need this ping anymore, or ping with all agents in the pool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants