Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
hi all...

i have a serious problem. below is my code:
C#
 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
Updated 7-Sep-12 18:02pm
v4
Comments
[no name] 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 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..
[no name] 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 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 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)

try this:

C#
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;
}

}
 
Share this answer
 
v2
Comments
tulasiram3975 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 7-Sep-12 12:20pm    
it's problem with your client settings.
tulasiram3975 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
[no name] 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 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..
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!
 
Share this answer
 
Server Error in '/' Application.
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 [2607:f8b0:4003:c06::6c]:25
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 [2607:f8b0:4003:c06::6c]:25

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

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 [2607:f8b0:4003:c06::6c]:25]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +208
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +464

[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) +6651460
System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) +307
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +19
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +324
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +141
System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +170
System.Net.Mail.SmtpClient.GetConnection() +44
System.Net.Mail.SmtpClient.Send(MailMessage message) +1554

[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1906
FlexiMail.Send() in d:\projects\hotelsBooking\App_Code\FlexiMail.cs:206
SendMail.Cancelmail(String UserName) in d:\projects\hotelsBooking\App_Code\SendMail.cs:155
Admin_BookingsView.btncancel_Click(Object sender, ImageClickEventArgs e) in d:\projects\hotelsBooking\Admin\BookingsView.aspx.cs:228
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +124
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) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
 
Share this answer
 
Comments
Deepu S Nair 11-Feb-15 23:53pm    
?
Member 11904360 25-Nov-15 8:05am    
so far all the above solutions have failed to yield a good result for me , I still the same above problem. Anyone who managed to solve it differently?
ranjeet42 12-May-17 7:27am    
Did you find any soln. for this I am also getting same error .using 1&1 hosting on local it works fine.

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