【问题标题】:Setting the timeout of a HAPI FHIR IGenericClient设置 HAPI FHIR IGenericClient 的超时
【发布时间】:2017-01-11 15:10:17
【问题描述】:

我正在尝试使用以下代码运行 fhir 搜索;

FhirContext ctx = FhirContext.forDstu2();
ctx.getRestfulClientFactory().setConnectTimeout(2000000);
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2");

Bundle results = client.search().forResource(Basic.class).returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).execute();

但是当它运行时,它总是抛出由异常“SocketTimeoutException”引起的异常“FhirClientConnectionException”。我是否可以假设这是服务器超时,而不是我的本地连接,因为我将本地设置为 2000000?

我该如何解决问题?我在开箱即用的配置中使用 HAPI,它在大约 10-15 秒内搜索相对少量的资源时超时。

【问题讨论】:

    标签: dstu2-fhir hl7-fhir hapi-fhir


    【解决方案1】:

    改用setSocketTimeout()

    像这样:

    FhirContext ctx = FhirContext.forDstu2();
    ctx.getRestfulClientFactory().setSocketTimeout(200 * 1000);
    IGenericClient client = ctx.newRestfulGenericClient("http://localhost:1080/hapi-fhir-jpaserver-example/baseDstu2");
    
    Bundle results = client.search().forResource(Basic.class).returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).execute();
    

    v3 示例:

    serverBase =  "http://hapi.fhir.org/baseDstu3";
    ctx = FhirContext.forDstu3();
    ctx.getRestfulClientFactory().setSocketTimeout(200 * 1000);
    
    // Create the client
    client = ctx.newRestfulGenericClient(serverBase);
    

    我在这里找到了阅读源代码的答案:https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3Test.java#L1710

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      • 2020-08-20
      • 1970-01-01
      • 2023-04-01
      • 2020-11-24
      • 1970-01-01
      相关资源
      最近更新 更多