How to fix 'The underlying connection was closed: An unexpected error occurred on a send'
By Tan Lee Published on Feb 16, 2024 1.28K
The error "The underlying connection was closed: An unexpected error occurred on a send." typically occurs when there's a problem with the SSL/TLS communication between your application and the server.
This issue can be related to several factors, such as SSL/TLS protocol mismatches, server configuration issues, or network problems.
To solve the problem you should set the configuration as the following c# code.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
You can add the code above in the Program class.
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmFluentDesignForm()); } }
I hope so you can solve the problem when using RestSharp library with https protocol.
Categories
Popular Posts
Structured Data using FoxLearn.JsonLd
Jun 20, 2025
Implement security headers for an ASP.NET Core
Jun 24, 2025
Modular Admin Template
Nov 14, 2024
SB Admin Template
Nov 14, 2024
Carpatin Admin Dashboard Template
Nov 15, 2024