c# WebRequest error An existing connection was forcibly closed by the remote host

“An error occurred while making the HTTP request to https://<API endpoint>. 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.” Inner exception was “Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

this happened to me when doing some HttpWebRequests and suddenly everything stopped working.


apparently the server changed protocol to Tls1.2, and that caused all the mess. PLUS i was using .Net4 so no enum there, so here is the magic line for all you problems 


ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

Asp.Net Ending Response options, Response.End() vs CompleteRequest()