0
votes

I am trying to deploy PayPal application to IIS.

I cannot connect to PayPal due to issue with TLS1.2

I did all changes to the registry and using .Net 4.6.1

If I use this code on console application

        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        using (var response = WebRequest.Create("https://tlstest.paypal.com/").GetResponse())
        using (var streamReader = new StreamReader(response.GetResponseStream()))
        {
            Console.WriteLine(streamReader.ReadToEnd());
        }

it works.

Same code put in asp.net application and deployed to IIS on the same server does not work.

Any ideas why console application is working and asp.net application deployed on IIS is not?

Error:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 104.75.235.58:443 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: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 104.75.235.58:443

Source Error:

Line 16: System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; Line 17: Line 18: using (var response = WebRequest.Create("https://tlstest.paypal.com/").GetResponse()) Line 19: using (var streamReader = new StreamReader(response.GetResponseStream())) Line 20: {

Source File: C:\WebApplication2\WebApplication2\WebForm1.aspx.cs Line: 18

Stack Trace:

[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 104.75.235.58:443] System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +185 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +506

[WebException: Unable to connect to the remote server] System.Net.HttpWebRequest.GetResponse() +1390 WebApplication2.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Temp\Razno\PPtest\WebApplication2\WebApplication2\WebForm1.aspx.cs:18 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +95 System.Web.UI.Control.LoadRecursive() +59 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

1
Console.WriteLine will not work in asp.net application. Can you please provide code for us, how you did it in asp.net appVictor Leontyev
As I am saying the same code deployed in web forms project in aspx page instead of console. writleln I have put string a = streamReader.ReadToEnd();, but that is not relevant since the app is not reaching that part in aspx applicationNikola
Please add what exception you are getting and stack trace as well.Rohith

1 Answers

0
votes

You are getting a socket error and not a ssl issue.

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Your application is not able to connect to the said address https://tlstest.paypal.com/. This may be due to proxy setting where your console application will be working under your credential and going on the default proxy setup but IIS(w3wp.exe ) is not able to. Please try and add the proxy settings. Refer this as well

Also this SO post discuss the same