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

Fix issue with destroying proxy agent #46

Merged
merged 1 commit into from
Jan 30, 2018
Merged

Conversation

omeshp
Copy link
Contributor

@omeshp omeshp commented Dec 8, 2017

Proxy agent doesn't support destroy function

Proxy agent doesn't support destroy function
this._proxyAgent.destroy();
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about keep alives? Does proxy support that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the testing I didn't it seemed to reuse sockets, but at https://github.com/koichik/node-tunnel/blob/master/lib/tunnel.js I don't see any keepAlive. I will have to retest to validate. I can try it out on Friday.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also asked Ting to test and chime in on Proxy since he did most of that work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TingluoHuang keepalive will still work if maxSocket is Infinity. maxSockets is for throttling requests. In node agent (https://nodejs.org/api/http.html#http_class_http_agent) the default value of maxSockets is Infinity, but I am ok with restricting it to 100 here.

proxyAgent doesn't support destroy function, so we don't have a choice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephenmichaelf it's possible if you are using proxy at the same time.
@omeshp i think there might be something wrong in the tunnel lib which cause the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TingluoHuang I didn't get the issue stephen is facing. Are you saying that keepAlive isn't honored in case of proxy if maxSockets isn't set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TingluoHuang @stephenmichaelf I think tunnel agent maintains list of sockets and reuses them (https://github.com/koichik/node-tunnel/blob/master/lib/tunnel.js#L58) by default, so sending keepAlive in proxy case won't matter, but this PR should go through since destroy function isn't supported in tunnel agent and users will get error while calling dispose on typed-rest-client.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TingluoHuang Maybe this is why we were seeing unexpected keep-alive results? Since this code is using tunnel and not the standard node sockets.

@omeshp To clarify, this is different than node's standard usage of sockets. We had some issues adding NTLM to this library due to node dropping sockets if there wasn't a request queued up on the socket when the initial request finished. I think this unique functionality in tunnel to reuse sockets is why this code is working. In NTLM we ended up using callbacks and setImmediate. Are you familiar with this? Is this what you would expect?

@bryanmacfarlane
Copy link
Contributor

@TingluoHuang for review and proxy testing

@stephenmichaelf
Copy link
Member

@TingluoHuang @omeshp Where are we on this?

@bryanmacfarlane bryanmacfarlane merged commit dffabe6 into master Jan 30, 2018
@bryanmacfarlane
Copy link
Contributor

released as 1.0.6

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

Successfully merging this pull request may close these issues.

4 participants