Reputation: 3522
I've ran a query on a hapi fhir database which has returned a paged result back to me. I'm using hapi base in java to actually do the search, as per the documentation here: http://hapifhir.io/doc_rest_client.html
Bundle bundle = client.search().forResource(Basic.class).returnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).execute();
do {
for (Entry entry: bundle.getEntry())
System.out.println(entry.getFullUrl());
if (bundle.getLink(Bundle.LINK_NEXT) != null)
bundle = client.loadPage().next(bundle).execute();
else
bundle = null;
}
while (bundle != null);
The code runs as far as getting the first bundle, and prints out the urls as expected, however when it tries to execute the next bundle, I get a ConnectionException 'Connection refused: connect'.
The server still appears to be responsive however as I can rerun my program and have the exact same result returned.
Any idea why the connection would be being refused? I get a similar issue when I try to run it manually from postman.
Upvotes: 2
Views: 2367
Reputation: 3522
Just in case anyone stumbles across this. I had some sort of redirection going on (setup by another member of my team). Essentially my base url was localhost:8080, but the next address was returning as localhost:1080 (which I don't entirely understand why).
He changed a config in the server to make it not redirect.
Upvotes: 0
Reputation: 701
What you're doing certainly looks correct. If you perform a search manually (say, using a browser or postman or whatever) what does the next link look like? And does it work if you use that link directly in a browser too?
For example, if I run the CLI locally on my machine, and execute a search I see the following in the response:
"link": [
{
"relation": "self",
"url": "http://localhost:8080/baseDstu3/_history"
},
{
"relation": "next",
"url": "http://localhost:8080/baseDstu3?_getpages=d8454866-624d-4bb3-b7a0-0858e4870e7e&_getpagesoffset=10&_count=10&_pretty=true&_bundletype=history"
}
],
If I plug the next link (http://localhost:8080/baseDstu3?_getpages=d8454866-624d-4bb3-b7a0-0858e4870e7e&_getpagesoffset=10&_count=10&_pretty=true&_bundletype=history
) into a browser, I get the next page.
Can you try this and see how it goes?
Upvotes: 4