15
Views
9
Comments
Consuming Rest API: The underlying connection was closed:An unexpected error occurred
Application Type
Mobile
Service Studio Version
11.9.1 (Build 33435)

I am trying to consume an extremely simple Rest, a call to a public endpoint: https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/metadata

Calling this endpoint from a browser or with Postman gives the expected response, no problems, no errors. The domain of the external called endpoint supports TLS 1.2, I have checked that.

Calling this endpoint from the Outsystems platform (11.9.1) however gives me an error as shown below, The underlying connection was closed: An unexpected error occurred on a send. More details below.

 This can be reproduced on the development platform in the Logic/Integrations/Rest/Consume Rest API  interface and simply using the endpoint URL mentioned above. See error message detail below.

I have read most posts about similar issues on this Forum, but those posts are mostly years old and/or the "resolution" does not apply. Hence this new post.

Any suggestions? I am pretty much hopeless at this point. Thanks Denis.


The underlying connection was closed: An unexpected error occurred on a send.

[1] The underlying connection was closed: An unexpected error occurred on a send.
at System.Net.HttpWebRequest.GetResponse()
at sssantecure.CcEpicProduction.ActionGetMetadata(HeContext heContext, ICcEpicProductionCallbacks _callbacks, String inParamAccept, Int32 inParamProxy, String inParamEHR, STInstanceStructure& outParamResponse)

[2] Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)

Rank: #70

Hi Denis,


I tried to call the REST API for that entrypoint and it went well:


What I did in Service Studio was add a Rest Service for the entrypoint you mentioned, test it and choose the option Copy to Response Body before Finish (and of course then call the service from a timer or button on a screen to test):


I'm using Service Studio 11.10.0 but I doubt it is because of the Service Studio version that it is not working on your side.


May it be that you have called this web service so many times that they blocked calls from your OutSystems infrastructure IP (hence the error message)?


Regards,
João

Rank: #2886

Dear João,

Thank you for your kind help. Unfortunately, I am doing exactly the same as you are doing and I am getting the error message as mentioned before. Even in the platform Rest set-up screen as you have shown above. Where you are showing the correct response, I am getting the error.

I don't think this API provider closes off an IP address for this public API, but I will certainly check again. Remains the platform version?? Could it be as I am using 11.9.1 build 33435??

Regards and thanks again for your rapid response.

mvp_badge
MVP
Rank: #72

Hi Denis,

This may happen because of a firewall blockage around your OutSystems infrastructure.

Make sure the connection (host, protocol, port) is allowed.

Regards,

Nordin

Rank: #2886

So I did check with the API provider if my IP address (actually Outsystems' IP address as I am using the hosted Personal environment) could be blacklisted, but this is definitely not the case. And again, the request works perfectly fine from Postman or any browser. I do know that the endpoint only support TLS 1.2. But I assume that is not the issue, as I am make successful requests to other endpoints that only support TLS 1.2.

Anybody any suggestions why my REST requests from the Outsystems Environment could continue to give the same error message? Thanks!