Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET MySQL
hi all...
 
i have a serious problem. below is my code:
 string ret = GetPageContent("http://202.xx.xx.xx/smpp.sms?username=12341234&password=12345&to=919999999999&from=AD-ADAD&text=Dear Parent,testing...");
 public static string GetPageContent(string FullUri)
    {
 
 HttpWebRequest Request;
        StreamReader ResponseReader;
        Request = ((HttpWebRequest)(WebRequest.Create(FullUri)));
        ResponseReader = new StreamReader(Request.GetResponse().GetResponseStream());
        return ResponseReader.ReadToEnd();
}
it is run on my system from vs 2008 or from IIS working fine...
but when installing in client pc it is throwing an exception
"Unable to connect to the remote server"
after a long search on internet i found some suggestions like including some changes in web.config file like
<system.net> 
     <defaultProxy> 
        <proxy 
           proxyaddress = "http://202.xx.xx.xx" 
           bypassonlocal = "true" /> 
     </defaultProxy> 
  </system.net>
 
and also am getting the same error after that i opened command prompt and type ping 202.xx.xx.xx it is show timeout for every request packets sent 4 recieved 0 (100% loss) is showed in command prompt
and also done with another process like:
i just uninstalled anti-virus and turned-off firewall and also not woking...
 
i spand lack of time in internet am still unable find solution please can any help me please
 
thanks in advance...
Posted 7-Sep-12 6:35am
Edited 7-Sep-12 19:02pm
v4
Comments
learner'sbug at 7-Sep-12 11:45am
   
It is a networking issue on your client computer.you might find this (http://social.technet.microsoft.com/Forums/en-US/Forefrontedgegeneral/thread/0136537c-65f5-4d66-8d75-e65dd92a403c/) useful.
tulasiram3975 at 7-Sep-12 11:47am
   
sir that is different issue error code 10060.but in my case it is likeSocketException (0x274c)
i have just hosted on clients local iis server..
may i solve the issue through programming sir..
learner'sbug at 7-Sep-12 11:51am
   
If FullUri is valid and has correct credentials..then I am afraid not..System.Net.Sockets.SocketException suggests error with creation of connection..
tulasiram3975 at 7-Sep-12 11:56am
   
fulluri is valid and have correct credentials sir because it is working on my local iis server. i think it is taking long time to respond and finally showing unable to connect remote server
tulasiram3975 at 7-Sep-12 12:27pm
   
fulluri is valid and have correct credentials sir because it is working on my local iis server. i think it is taking long time to respond and finally showing unable to connect remote server
and in cmd prompt ping 202.xx.xx.xx--> it is show timeout for every request packets sent 4 recieved 0 (100% loss)
tulasiram3975 at 7-Sep-12 11:58am
   
for more details regarding the 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 202.xx.67.xx:80
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 202.62.67.34:80

Source Error:

Collapse | Copy Code

Line 471: StreamReader ResponseReader;
Line 472: Request = ((HttpWebRequest)(WebRequest.Create(FullUri)));
Line 473: ResponseReader = new StreamReader(Request.GetResponse().GetResponseStream());
Line 474: return ResponseReader.ReadToEnd();
Line 475: }

 
Source File: c:\inetpub\wwwroot\vardhaman\fees\createuser.aspx.cs Line: 473

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 202.xx.xx.xx:80]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetResponse() +5386189
fees_createuser.GetPageContent(String FullUri) in c:\inetpub\wwwroot\vardhaman\fees\createuser.aspx.cs:473
fees_createuser.Testmsgbtn_Click(Object sender, ImageClickEventArgs e) in c:\inetpub\wwwroot\vardhaman\fees\createuser.aspx.cs:455
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +108
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +118
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 
Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5420

please can any help me please

thanks in advance..
tulasiram3975 at 7-Sep-12 12:35pm
   
this is all i had sir...
i had many things but am just post some thing so that people understand quickly and find solution quickly..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this:
 
public static string GET(string url)
{
    string webresponse = string.Empty;
    try
    {
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
        request.Method = "GET";
        request.AllowAutoRedirect = false;
        request.Credentials = CredentialCache.DefaultCredentials;
        request.Accept = "*/*";
        request.ContentType = "application/x-www-form-urlencoded";
        request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
        try
        {
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader SR = new StreamReader(dataStream, Encoding.UTF8);
            webresponse = SR.ReadToEnd();
            response.Close();
            dataStream.Close();
            SR.Close();
 
        }
        finally
        {
            request.Abort();
        }
 
    }
    catch { }
    return webresponse;
}
 
}
  Permalink  
v2
Comments
tulasiram3975 at 7-Sep-12 12:18pm
   
sir i got the same problem after using your code block at this line : HttpWebResponse response = (HttpWebResponse)request.GetResponse();
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 202.xx.xx.xx:80
sir may i change any internet settings in client PC or any other changes required..
Kuthuparakkal at 7-Sep-12 12:20pm
   
it's problem with your client settings.
tulasiram3975 at 7-Sep-12 12:30pm
   
ok can i change those settings. right now am connected with client PC
am unable to find where it is blocking my request in client PC
i just uninstalled anti-virus and turned-off firewall and also not woking
learner'sbug at 7-Sep-12 16:14pm
   
If you can not ping from client's system to 202.xx.xx.xx, then there is no use in looking through the code.
tulasiram3975 at 8-Sep-12 0:00am
   
internet is working in client PC ping his ip address it is showing correct (0% loss) but ping our API server address it is not showing..(100% loss) how can i rectify this problem please help me..
Kuthuparakkal at 10-Sep-12 2:00am
   
is it stand alone PC or in a Network ? If on a network so you can ask your network admin to create an exception on firewall to access the API machine.
tulasiram3975 at 13-Sep-12 0:42am
   
ok sir... but i did some changes in control panel-->windows firewall -> inbound --> created one rule ..
but it did't worked for me..
Kuthuparakkal at 13-Sep-12 1:15am
   
try to access the url using a browser from your client machine.
tulasiram3975 at 20-Sep-12 5:42am
   
i did it sir..
it is taking and processing request and displaying result..
but from code it is not taking..
i dont know why..??
Kuthuparakkal at 20-Sep-12 6:21am
   
try
request.Credentials = CredentialCache.DefaultCredentials;
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

The below line solved my timeout problem while GetResponse()
 
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
 
Thanks mate!
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 200
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 169
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 8 May 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100