Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have a trouble I am trying to create asp.net log in with google. The problem occur in getting user data from google "The underlying connection was closed: An unexpected error occurred on a send.".It was fine locally but when I was published and uploaded to server that error was faced. Please help me...
Best Regard

What I have tried:

C#
const int maxConnections = 1000; 
                ServicePointManager.DefaultConnectionLimit = maxConnections;
                const int maxIdleTimeout = 5000;
                ServicePointManager.MaxServicePointIdleTime = maxIdleTimeout;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                WebClient webClient = new WebClient();
                Stream stream = webClient.OpenRead("https://www.googleapis.com/oauth2/v1/userinfo?access_token=[AccessToken]");

                string b;

                using (StreamReader br = new StreamReader(stream))
                {
                    b = br.ReadToEnd();
                }
Posted
Updated 6-Jul-16 4:20am
v3
Comments
xszaboj 6-Jul-16 6:42am    
works like this for me. Only thing I changed was OpenRead("https://www.googleapis.com/oauth2/v1/userinfo?access_token=[AccessToken]"); -> OpenRead("https://www.google.co.uk");
Myo Zaw Latt 6-Jul-16 6:50am    
It is locally fine but when I had published and upload to server with iis7 that error was faced.
xszaboj 6-Jul-16 8:01am    
I've tried it on iis and works for me fine as well. Check you configuration if you don't block any request on your firewall maybe?
koolprasad2003 6-Jul-16 7:49am    
Try to set
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; rather than Ssl3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900