The underlying connection was closed – REST API call over HTTPS

The underlying connection was closed – REST API call over HTTPS

 

The sample code looks like this:

Despite the use of the WebClient, HttpWebRequest, or WebRequest classes in C #, the same failure continued to occur.

The underlying connection was closed: An unexpected error occurred on a send.

The answer was in a secure connection by default in Windows. Basically TLS or SSL3 attempts to establish a secure connection. If the attempt fails, an issue occurs because the connection is blocked without negotiating the reconnection.

It is resolved by putting the following code before WebClient (or WebRequest or HttpWebRequest) is instantiated.

That’s all, So simple is it?

Facebook Comments

Leave A Reply

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다

This site uses Akismet to reduce spam. Learn how your comment data is processed.