Cannot consume RESTful API on same app or server

Cannot consume RESTful API on same app or server

  
Version 9.1.0.20.

I created a simple RESTful API (return a list of names) in App 1 module 1, when try to consume it in App 1 module 2 or App 2 module 1, always got "The underlying connection was closed: An unexpected error occurred on a send." There is no error logged in Service Center.

It works when consume it on another server or test it in a browser.

Is there anyway to make it work or this is a limitation of OutSystems platform?

Thanks,
Stanley
Hi there,

I don't think this is a platform limitation at all. In fact I just tested it in my own Personal Environment and works just fine. Are you trying this on your Personal Environment? Could there be some network issues? Can you access the service's documentation page?

Cheers!

I can access the documentation page in the browser and the API works in a browser too, it also works when I connect service studio to another server and consume it from a new app. Both servers are on the same company network. It does not seem like a network issue either. Below is the error stack:

[1] The underlying connection was closed: An unexpected error occurred on a send.
   at System.Net.HttpWebRequest.GetResponse()
   at ssStanleyTest.CcStanleyAPI.ActionGetParks(HeContext heContext, ICcStanleyAPICallbacks _callbacks)

[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.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)

[3] An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Hi Stanley,

I'm assuming that the ssl certificate is valid and that if you access the url on the server machine (using internet explorer) it works fine without having to manually accept a certificate exception, right?


Assuming that, from the error and googling a bit that usually happens when there are proxies between messing up the communication, but like Mario said there is no such limitation and should work fine.

To see if it's a proxy issue lets do a quick workaround. The extension I'm attaching to this reply has a method called Disable100Continue.
Try calling that action just before doing the rest call.

If that did not work, then another thing we could do is check the default versions of ssl/tls that are being used in your server.
Try calling the CheckSecurityProtocol method and writing the output value to a screen. The result should include "Tls".


Regards,
João Rosado
Hi João,

After setting the HTTP security to none, it works when Service Studio is connecting to the same server. Thanks for helping. Still don't understand why it works when Service Studio is connected to a didderent server.

Stanley
I have to revisit this because SSL is required. Using João's extension:
  • Calling Disable100Continue before the rest call does not work.
  • The protocols are: Tls, Tls11, Tls12
Even testing in the consume REST API window fails. Same error as before.
The server is an internal one for development, the certificate is a self-signing one, does this matter?


Hi Stanley,


Did you do the Internet Explorer test locally on the server that I asked on the previous post?

Go to your server and write the url exactly like you are using on the rest. It should not show a page to accept the certificate.

Having a self signed certificate means that you also need to set it as trusted on the machine (so it trusts itself).


Regards

João Rosado

After turn on SSL 2.0 and SSL 3.0 and use the IP address (with certificate warning) it works. Using the server name (as the exact url) got "This page can't be displayed", even I can ping the server name.

Solution
Adding the server name in hosts and it works in IE. Go back to Service Studio and it works now.

Thanks for the help!
Solution