freshworks / fresh-samples

Samples of code created by freshdesk
183 stars 182 forks source link

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

Open sarahbenjamin opened 6 years ago

sarahbenjamin commented 6 years ago

I am using the c# code and upon this line the connection was closed error message is thrown. What am I doing wrong?

HttpWebResponse response = (HttpWebResponse)request.GetResponse()

Using the sample code.

k2s commented 6 years ago

duplicate of #42

bhadana-rajesh commented 5 years ago

I am using c# code and still seeing same issue, can someone update the sample code. or let me know what i am doing wrong ?

karnati8 commented 5 years ago

I am also getting this all of a sudden. The same code worked last year on v1, but it is not working on v2 and gives this same error on the same line.

Yes, I do have this in: ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

And I'm using .Net 2.6.2

My sample code:

string apiPath = "/api/v2/tickets/1";
string fdDomain = "my_domain"; string apiKey = "my_api_key"; string jsonString = String.Empty; ; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://" + fdDomain + ".freshdesk.com" + apiPath); request.ContentType = "application/json"; request.Method = "GET"; string authInfo = apiKey + ":X"; authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); request.Headers["Authorization"] = "Basic " + authInfo;

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

        DataSet dsFreshdeskData = new DataSet();
        try
        {
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {

....

vinodkumartheking commented 5 years ago

DId any one found the exact solution for the issue ? i am getting response when we change .Net 4 and TLS1

Dev-blin commented 3 years ago

Hi Exactly the same issue I have.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

This line also does not work for me. Also upgrade the .net Framework to 4.7 which didnt work.

Kindly someone post your solution here.