jembi / openhim-core-js

The Open Health Information Mediator core component. OpenHIM Support: Post your query on OpenHIE Discourse using the #openhim tag https://discourse.ohie.org/
http://openhim.org
Mozilla Public License 2.0
69 stars 69 forks source link

Fix response sent from one openhim to another openhim instance #1229

Closed reagan-meant closed 4 months ago

reagan-meant commented 4 months ago

When one uses one openhim(A) to connect to another openhim instance(B) Instance B is on the same server with other services like opencr and SHR The issue is that the response from opencr or hapi fhir server is legible in the openhim(B) but the response sent to openhim(A) is illegible

rcrichton commented 4 months ago

HI, do you perhaps have a screenshot you can share with what it looks like?

reagan-meant commented 4 months ago

Postman Request

postman

Instance A received request and sent to instance B

instance A

Instance B requests the end services that returns response

instance B
rcrichton commented 4 months ago

Thanks for these. Do you mind sharing what the response headers where in each case?

Edit: I'm wondering if it's related to compression is anyway.

reagan-meant commented 4 months ago
headers postheader
reagan-meant commented 4 months ago

Probably postman shows br as encoding

rcrichton commented 4 months ago

Yes, you are right. Could you please share the screenshots again with both the request and response header section expanded? That would make it easier for me to follow what might be going on. I think the OpenHIM A is saying it supports compression and OpenHIM B then decided to use a compressed response but OpenHIM A it's not decompressing the response when sending it back to the client which doesn't support compression.

rcrichton commented 4 months ago

Some further findings. It seems OpenHIM support automatic decompression of deflate and gzip however we are getting br back in this example. So it's not decompressing the response.

https://github.com/jembi/openhim-core-js/blob/4ae2ac84b6a1ccf0561d7b7d5363413d221017f9/src/middleware/router.js#L592-L611

I'm not sure why br is being used right now.

reagan-meant commented 4 months ago
resphead1 resphead2
rcrichton commented 4 months ago

It looks like in your original request you are supplying the header accept-encoding: gzip, deflate, br which means the client support decompression but it seems postman doesn't. Perhaps you need to adjust that header on your request to remove br from the values or remove the header entirely.

reagan-meant commented 4 months ago

@rcrichton adjusting the accept-encoding fixes the issue. Thanks alot. cc @drizzentic