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

agentKeepALive recommendation probably not a great choice #29600

Closed
tony-gutierrez opened this issue Apr 17, 2019 — with docs.microsoft.com · 13 comments
Closed

agentKeepALive recommendation probably not a great choice #29600

tony-gutierrez opened this issue Apr 17, 2019 — with docs.microsoft.com · 13 comments

Comments

Copy link

This library has had a possible socket bug for a year now. There doesnt seem to be a great alternative, mainly because most environments have faster and more ports than Azure app services.
node-modules/agentkeepalive#57


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@DashleenBhandari-MSFT-zz

@tony-gutierrez , Thanks for raising this issue. I will check and update you.

@DashleenBhandari-MSFT-zz

Hi Tony,
Apologies for the delay.
Could you please try using the connection pooling that comes along with the Node version itself?
AgentKeepAlive is a node module. Connection pooling in the node module is built by open source community.
The Node runtime comes with the agent that can do connection pooling. In earlier versions of the node it did not function properly.
The newer node version may be better and we can try the connection pooling available with the module itself. Please let us know if this helps you.

@tony-gutierrez
Copy link
Author

tony-gutierrez commented May 8, 2019 via email

@DashleenBhandari-MSFT-zz

@tony-gutierrez , I would request you to open a support case with Azure App Services team. We would like to work closer with you.
Please let me know if you have a support plan already to open the support case.

@DashleenBhandari-MSFT-zz

@tony-gutierrez Please let us know if you need further assistance in opening a support ticket with us.

@tony-gutierrez
Copy link
Author

Ill attempt to find time to look into this with support, but feel that if MS is going to provide such a low port and slow port recycling to app service users, they should provide a solid port recycling strategy that does not rely on a buggy open agentkeepalive library with stalled development.

@DashleenBhandari-MSFT-zz

@tony-gutierrez , Thanks for the feedback and I will share this with the product group. It will definitely help if you will be able to open the support ticket.

@gunzip
Copy link

gunzip commented Apr 2, 2020

hi @tony-gutierrez, I've seen another comment of you here: Azure/azure-storage-node#455 (comment)

in the end, do you suggest to use the agentkeepalive library or go with the native nodejs agent support ? can you share some settings that worked well for you ? we're in the same route.

@PRMerger14 PRMerger14 added the Pri2 label Apr 2, 2020
@tony-gutierrez
Copy link
Author

tony-gutierrez commented Apr 2, 2020

@gunzip If you are hosting on an Azure app service, or talking to Azure APIs (cosmos, etc) you need agentkeepalive.

This is because microsoft servers drop a socket after 120seconds....whether it is active or idle. So no socket should live longer than that in your code. It's really dumb.

Here is what I use:

{
		keepAlive: true,
		maxSockets: 25,
		maxFreeSockets: 10,
		timeout: 60000,
		freeSocketTimeout: 30000, //not used if using normal agent
		socketActiveTTL: 110000 //ms lameness
	}

you might want to adjust maxSockets ....its per host, so the math is basically how many hosts are you reaching out to on a regular basis, and trying to keep that * maxSockets under the appservice limit...which is 160 or so, don't remember exactly.

@tony-gutierrez
Copy link
Author

As far as the bugs in agentkeepalive, no one could ever replicate the race condition, and in general it seems to be working pretty well. So my original complaint in the issue is probably not valid.

@jmsims2
Copy link

jmsims2 commented Oct 2, 2020

@tony-gutierrez Trying to get this to work on azure app service now...seeing intermittent ECONNRESET, terribly frustrating. Did you use this with expressjs or another library? Trying to integrate it now, but can't tell if it's working or not? How did you test to know it was working? Any help would be greatly appreciated!

@tony-gutierrez
Copy link
Author

I used express, with the configuration above. My belief is that you will never see 0 connreset errors on an azure app service.

@jmsims2
Copy link

jmsims2 commented Oct 2, 2020

Thanks @tony-gutierrez. We have a weird setup where we are making a lot of outbound connections to various Dynamics 365 or Salesforce CRM systems. We have never seen an issue with salesforce using their jsforce library, but see these with connecting to Dynamics using request-promise. Switching to axios and going to try using an agent with it, just trying to work through the implications of one client using an agent and another not.

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

No branches or pull requests

6 participants