首页 > 解决方案 > Kashflow .NET - An existing connection was forcibly closed by the remote host

问题描述

I am using the kashflow soap API found (https://www.kashflow.com/developers/soap-api/)

I have made no changes to the code, however, an error has just started as of today.

I will paste the full error below, any help greatly appreciated as staff can't work as needed with this issue breaking the application!

Server Error in '/' Application.
An existing connection was forcibly closed by the remote host
Description: An unhandled exception occurred during the execution of the current web request. Please 
review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by 
the remote host

Source Error:


Line 6967:        
Line 6968:        public int InsertOrUpdateProject(out string Status, out string StatusDetail, string 
UserName, string Password, KashFlow.Project Project) {
Line 6969:            return base.Channel.InsertOrUpdateProject(out Status, out StatusDetail, 
UserName, Password, Project);
Line 6970:        }
Line 6971:        

Source File: c:\Users\xx\AppData\Local\Temp\Temporary ASP.NET 
Files\vs\11510ad2\e6b292f4\App_WebReferences.dpd9l9xp.0.cs    Line: 6969

Stack Trace:


[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) 
+111
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +131

[IOException: Unable to read data from the transport connection: An existing connection was forcibly 
closed by the remote host.]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +299
System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) +32
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +164
System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, 
AsyncProtocolRequest asyncRequest) +297
System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest 
asyncRequest) +51
System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, 
AsyncProtocolRequest asyncRequest) +166
System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +573
System.Net.TlsStream.CallProcessAuthentication(Object state) +44
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback 
callback, Object state, Boolean preserveSyncCtx) +195
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, 
Object state, Boolean preserveSyncCtx) +22
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, 
Object state) +67
System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +803
System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +54
System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) +105
System.Net.ConnectStream.WriteHeaders(Boolean async) +449

[WebException: The underlying connection was closed: An unexpected error occurred on a send.]
System.Net.HttpWebRequest.GetResponse() +1463
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +56

[CommunicationException: An error occurred while making the HTTP request to 
https://securedwebapp.com/api/service.asmx. This could be due to the fact that the server certificate 
is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch 
of the security binding between the client and the server.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +159
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +353
KashFlow.KashFlowAPISoap.InsertOrUpdateProject(String& Status, String& StatusDetail, String UserName, 
String Password, Project Project) +0
KashFlow.KashFlowAPISoapClient.InsertOrUpdateProject(String& Status, String& StatusDetail, String 
UserName, String Password, Project Project) in c:\Users\xx\AppData\Local\Temp\Temporary 
ASP.NET Files\vs\11510ad2\e6b292f4\App_WebReferences.dpd9l9xp.0.cs:6969
we3.Dal.Quotes.InsertProjectIntoKashflow(Int32 quoteid, Boolean force) in 
C:\Users\xx\source\repos\xx\App_Code\xx\xx.vb:539
we3.Dal.Applications.CreateInvoice(Int32 applicationid) in 
C:\Users\xx\source\repos\xx\App_Code\xx\xx.vb:109
xx.btnKashflow_ServerClick(Object sender, EventArgs e) in 
C:\Users\xx\source\repos\xx\xx\xx\xx.aspx.vb:317
System.Web.UI.HtmlControls.HtmlAnchor.OnServerClick(EventArgs e) +121
System.Web.UI.HtmlControls.HtmlAnchor.RaisePostBackEvent(String eventArgument) +108
System.Web.UI.HtmlControls.HtmlAnchor.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String 
eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9845228
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean 
includeStagesAfterAsyncPoint) +1696

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

标签: asp.net

解决方案


我今天也收到了这个 Kashflow 错误。似乎 Kashflow 已将其结尾更新为 TLS12。在您的 API 调用之前将其添加到某处,它应该有望完成这项工作:

 System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

推荐阅读