Setting socket timeout

358 views
Skip to first unread message

Al Amyot

unread,
Apr 24, 2015, 12:11:02 PM4/24/15
to hapi...@googlegroups.com
Using the HAPI client and DSTU1 test server, I get java.net.SocketTimeoutException on a Patient search. I have not been able to understand how to set a higher timeout value.

My current code uses the faults:

ctx = new FhirContext();
client = ctx.newRestfulGenericClient(url);

However I also tried this:

ctx = new FhirContext();
RestfulClientFactory f = (RestfulClientFactory)ctx.getRestfulClientFactory();
f.setConnectionRequestTimeout(20);
f.setConnectTimeout(20);
f.setSocketTimeout(20);
client = f.newGenericClient(url);

and got an exception "unable to retrieve server metadata"

Does anyone have an example of setting the timeout correctly? Also, an explanation of the 3 different settings?


James Agnew

unread,
Apr 24, 2015, 12:35:30 PM4/24/15
to Al Amyot, hapi...@googlegroups.com
Hi Al,

Those values are in milliseconds, so you probably want to bump them up to (20 * 1000).

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/1c4567bc-416b-4682-a9c9-92147860985e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Al Amyot

unread,
Apr 24, 2015, 12:44:07 PM4/24/15
to James Agnew, hapi...@googlegroups.com
Thanks but what is the proper syntax for the HAPI client James? My attempt to set the values cause the second error

Al Amyot

unread,
Apr 24, 2015, 12:44:49 PM4/24/15
to James Agnew, hapi...@googlegroups.com
Oh, because I used such a short setting, the metadata retrieval failed Duh!

On Fri, Apr 24, 2015 at 11:35 AM, James Agnew <james...@gmail.com> wrote:

James Agnew

unread,
Apr 24, 2015, 12:47:58 PM4/24/15
to Al Amyot, hapi...@googlegroups.com
I realized that there weren't any good example on our site of these settings.. The next site deploy will add some to the HTTP config page.

Cheers,
James
Reply all
Reply to author
Forward
0 new messages