2016-10-11 4 views
0

노드 j의 aws-sdk가 내부 풀을 통한 연결을 관리합니까?노드 js 연결 관리 용 AWS-SDK

그들의 설명서 종류는 저를 믿게합니다.

httpOptions (지도) - 낮은 수준의 HTTP 요청에 전달할 수있는 옵션 집합입니다. 현재 지원되는 옵션은 다음과 같습니다.

프록시 [문자열] - 에이전트를 통한 프록시 요청 URL [http.Agent, https.Agent] - HTTP 요청을 수행 할 Agent 객체입니다. 연결 풀링에 을 사용했습니다. 비 SSL 연결의 경우 글로벌 에이전트 (http.globalAgent)의 기본값입니다. SSL 연결의 경우 피어 인증서 확인을 사용하려면 특수 Agent 객체가 사용됩니다. 이 기능은 Node.js 환경에서만 사용할 수 있습니다.

그러나 적어도 내가 찾을 수있는 아무 것도 없기 때문에 연결 풀 속성을 정의 할 수 있습니다.

사용중인 동시 연결을 제어하려면 어떤 옵션이 있습니까?

SDK가 처리하도록하는 것이 더 좋습니까?

답변

2

은 최대 소켓에 대해 원하는 설정으로 http.Agent을 제공 할 수 있습니다.

+0

그러나이 SDK는 HTTPS에 대한 다른 사용자 에이전트를 사용하지? – Thihara

+0

비슷한 코드 예제를 참조하십시오. http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Registering_Certificate_Bundles – at0mzk

+0

감사합니다. – Thihara

1

나는 이것을 조금 더 조사했다.

저는 주위를 파고 기본값을 알아 냈습니다.

AWS-SDK는 노드 http을 사용하고 있으며 그 중 defaultSocketCountINFINITY입니다.

그들은 maxSocketCount50 인 포장 아래에 https 모듈을 사용하고 있습니다.

관련 코드 스 니펫.

sslAgent: function sslAgent() { 
    var https = require('https'); 

    if (!AWS.NodeHttpClient.sslAgent) { 
     AWS.NodeHttpClient.sslAgent = new https.Agent({rejectUnauthorized: true}); 
     AWS.NodeHttpClient.sslAgent.setMaxListeners(0); 

     // delegate maxSockets to globalAgent, set a default limit of 50 if current value is Infinity. 
     // Users can bypass this default by supplying their own Agent as part of SDK configuration. 
     Object.defineProperty(AWS.NodeHttpClient.sslAgent, 'maxSockets', { 
     enumerable: true, 
     get: function() { 
      var defaultMaxSockets = 50; 
      var globalAgent = https.globalAgent; 
      if (globalAgent && globalAgent.maxSockets !== Infinity && typeof globalAgent.maxSockets === 'number') { 
      return globalAgent.maxSockets; 
      } 
      return defaultMaxSockets; 
     } 
     }); 
    } 
    return AWS.NodeHttpClient.sslAgent; 
    } 

소켓 수를 조작하려면 BretzL의 답변을 참조하십시오.

그러나 지금은 httphttps에 대한 에이전트를 동시에 설정하는 방법이 있습니다. http에서 https으로 전환 할 때 구성을 업데이트하면이 문제를 해결할 수 있습니다.

참조 : https://github.com/aws/aws-sdk-js/issues/1185