title: FhirContext reusing best practice returns exception "Timeout waiting for connection from pool"
body: <p>I am having a jsp which makes 25 hl7 hapi fhir calls asynchronously using dstu2. As suggested in best practices, I am creating the fhir context once using static loading and reusing it in every service call. However, service calls fail intermittently with the below stack trace: (I initialized the fhir context for every service call and this issue gets resolved. However, this is slowing down the calls. Could someone help me with any alternative approaches or tell me what I am doing wrong)</p>
  
  <p>Caused by: org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool</p>
  
  <p>public class MyFHIRContext{</p>
  
  <pre><code>public static FhirContext ctx;
  
  static{
      ctx = FhirContext.forDstu2();
      ctx.getRestfulClientFactory().setSocketTimeout(60 * 1000); 
      ctx.getRestfulClientFactory().setConnectTimeout(60 * 1000); 
      ctx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>calling code:
  IGenericClient client = MyFHIRContext.ctx.newRestfulGenericClient("server url");</p>