dstu2-fhir - 设置 HAPI FHIR IGenericClient 的超时时间

标签 dstu2-fhir hl7-fhir hapi-fhir

我正在尝试使用以下代码运行 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();

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

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

最佳答案

改为尝试 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

关于dstu2-fhir - 设置 HAPI FHIR IGenericClient 的超时时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41594321/

相关文章:

hl7-fhir - 从 V2 消息创建/更新患者资源时如何避免重复

hl7 - 访问 bundle HL7-FHIR 中的资源

flutter - 使用 HAPI FHIR 发布资源包

hl7-fhir - 如何表示 .NET FHIR DSTU 2 模型中包含的资源

dstu2-fhir - Smart On FHIR 和 FHIR-NET-API 的目的

angular - 我如何在 Angular cli 项目中使用 @types/fhir

hapi-fhir - 如何通过 FHIR REST api (HAPI) 添加配置文件

hl7-fhir - 如何在 FHIR 中存储用户健身/健身设备数据?

javascript - AngularJS $http.get 异步执行顺序