FULL VIDEO REVIEW:
In this video, we talk about “An existing connection was forcibly closed by the remote host” and how to resolve the error.
https://youtu.be/LO-AFAK1g0w
Error:
ERROR Text: Recieved when calling site (seen on back end server) (go to the where the site is installed to see the error unless you are displaying errors on your outword site):
Server Error in ‘/TESTING/…’ 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:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +226
[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) +811
System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) +48
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +228
System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) +361
System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest, Boolean renegotiation) +245
System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +812
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +370
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +21
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +85
System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +1131
System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +62
System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) +124
System.Net.ConnectStream.WriteHeaders(Boolean async) +491
[WebException: The underlying connection was closed: An unexpected error occurred on a send.]
System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data) +758
Base.Login.LoginAttemptServiceSync(String loginId, String screenSize, String loginAttemptServiceurl, String useragent, String browser, String version, String platform, String projectName, String instrumentId, String disposition, String eventId, String leadingEventId, String password, String endUrl, String isJavaScriptEnbled, String isCookiesEnabled, String ipAddress, String productVersion, String respondentEnteredUrl) in C:…Login.cs:365
…Logon.Logon_Click(Object sender, EventArgs e) in C:…Logon.aspx.cs:1054
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11596288
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +274
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1890
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0
How To Steps
- Debug your code to find which end point is causing your problem.
- In that method call, put the below code, ABOVE where the issue occurs (inside the method). Note: This is NOT a using statement you need to copy the EXACT code right inside your method call to your endpoint or what ever is giving you a issue.
-
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
-
NOTE: Check your web.config to make sure it is not pointing to an empty string for the end point that can cause this error as well.
-
The above code should fix it right away.
Conclusion
The issue occurs because the wrong version of TLS is being called, perhaps the .dlls or something for the End Point you are connecting to has be updated or changed. The above-mentioned piece of code allows for providing alternative TLS versions to be called.
*SUBSCRIBE LINK:* SUBSCRIBE NOW
PRODUCT DETAILS
- N/A
Suggestions for the Manufacturer
- N/A
OTHER VIDEOS / Blog Post Recommendations
- N/A
References:
IMPORTANT
Thank you for your support please remember to like and subscribe, ring the notification bell and leave a comment!!
*SUBSCRIBE LINK:* SUBSCRIBE NOW