我正在尝试使用以下代码进行第一次搜索;
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秒内搜索相对少量的资源会超时。
改为尝试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);