Intermittent error connencting to companies house api Issues

Hello,

I am connecting to Companies house API to retrieve company results. This is done using c# and deployed on top of SharePoint.

When I deploy the solution, the API connection intially works. But after few minutes It stop working and gives the below error. Sometimes it gets resolved if I do an iisreset. I raiased this question as conitnuation of another issue, but didnt get any reply. So, raising as a fresh question. This is urgent, as this is holding the application to go to Production.

“Authentication failed because the remote party has closed the transport stream.”

Stack trace:

at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, 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)

Adding addional information on the issue:

The companies house api connection code is residing in a library. When I access it from SharePoint web application, it works for sometime and then stops working.

At this point I createed a c# console application referenced the same class library and it is able to connect to companies house api.

Does this mean that your C# console, which is does not involve Sharepoint, is working as you expect?

Chris

Hi Chris

Yes, I would assume so. Even with SharePoint (in turn a asp.net application hosted in IIS) I guess its just a call to external api… I dont know if there is any specific nuance that I am mising to understand here!

If SharePoint is downstream of your network connection to our API, then perhaps it is forcing the disconnect? For example, when running within SharePoint, is your network connection going via a proxy? Is SharePoint the proxy? That kind of thing.

When we see network issues such as yours which appear to work in one environment and not (or intermittently) in another, then it is often that working environment is making a direct connection to our API, and the failing/intermittent environment is not…

Worth checking.