This is a discussion on HTTP Web Response Exception - I cant able to trap. within the Windows Mobile forums, part of the Mobile Software Development category; Intermittent error With HTTPWebRequest We have a service which runs at one hour and checks if configured URI's are ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Intermittent error With HTTPWebRequest We have a service which runs at one hour and checks if configured URI's are working (UP) or not. We have around 10 URI's to check. Strangely for for one particular URI which is giving intermittent error: Error Message : The underlying connection was closed: Unable to connect to the remote server. Error Source : System Error Exception : System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server. at System.Net.HttpWebRequest.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult) at System.Net.HttpWebRequest.GetResponse() Generally this error we get when we the destination website is down. But thats not the case the website is fully functional. Here is my code: StreamReader objSR = null; HttpWebRequest objRequest = null; HttpWebResponse objResponse = null; try { objRequest = (HttpWebRequest) HttpWebRequest.Create(ser.ServiceInfo.Name.ToStrin g()); objResponse = (HttpWebResponse) objRequest.GetResponse(); objSR = new StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.ASCII); System.Text.StringBuilder sb = new System.Text.StringBuilder(); Pls let us know if there is something wrong..or any alternate solution!!!! |
| Sponsored Links |
| |||
| Check the machine using the IP address, not the URI to verify it is working. It is possible that the machine name resolves to a wrong IP address and goes to another machine For example if you have a url like that: http://yourmachinename/path/file go to http://correctip/path/file |
| |||
| hi guys Hope this is a mobile application development forum. I have some problem in my j2me application code. Actuallu the error in Initializing http tunnel connection. i had written a simple program using wtk2 for http connection. and i got a runtime error as listed below. java.io.IOException: Error initializing HTTP tunnel connection: HTTP/1.1 400 Bad Request Server: Microsoft-IIS/5.0 Date: Mon, 27 Jan 2003 10:56:14 GMT Connection: close Content-Length: 4009 Content-Type: text/html at com.sun.midp.io.j2me.http.Protocol.doTunnelHandsha ke(+282) at com.sun.midp.io.j2me.http.Protocol.connect(+119) at com.sun.midp.io.j2me.http.Protocol.streamConnect(+ 44) at com.sun.midp.io.j2me.http.Protocol.startRequest(+1 2) at com.sun.midp.io.j2me.http.Protocol.sendRequest(+38 ) at com.sun.midp.io.j2me.http.Protocol.sendRequest(+6) at com.sun.midp.io.j2me.http.Protocol.openInputStream (+9) at HTTPMIDlet.sendGetRequest(+42) at HTTPMIDlet.commandAction(+29) at javax.microedition.lcdui.Display$DisplayAccessor.c ommandAction(+284) at javax.microedition.lcdui.Display$DisplayManagerImp l.commandAction(+10) at com.sun.midp.lcdui.DefaultEventHandler.commandEven t(+68) at com.sun.midp.lcdui.AutomatedEventHandler.commandEv ent(+47) at com.sun.midp.lcdui.DefaultEventHandler$QueuedEvent Handler.run(+250) i am not sure of the cause of such an error and whether some settings have to be changed for http connectivity... i would be glad if someone could help me out with this... thanks |
| |||
| Hi, I face the same problem but with a different HTTP error message - "403 Forbidden". If you're behind a firewall, have you set the proxy ? I use the Sun One studio and in that, if you go to the explorer->runtime settings and choose your installed emulator, the proxy can be set in Preferences. |
| |||
| Try to change HTTP proxy from HTTP 1.0 to 1.1 or vice versa. |
| |||
| Hi , I too got the same error like, java.io.IOException: Error initializing HTTP tunnel connection: HTTP/1.0 404 Not Found Server: servletrunner/2.0 Content-Type: text/html Content-Length: 95 Date: Wed, 03 Jan 2007 14:59:05 GMT Here I used J2ME as client application, through servlet runner I am tring to connect to server program. Initially Its worked fine.. But I changed some interner explorer settings. then I got this error. When I changed those setttings to normal also I am not able to connect to the server. Even I reinstall the whole softwares. But the problem is still there. So could any one help me to resolve the problem. Its very Urgent project. Its completed but when I try to demonstrate, that day only to connect my PC remotly I changed internet explorer settings very badly. It causes all the damage. Even I changed them to normal also I am not getting any. Please help me to resolve it. waiting for your response.... Thanks, |
| |||
| Hi, The low level Request and Response API to service incoming Http requests are Http Handlers in Asp.Net. All handlers implement the IHttpHandler interface, which is located in the System.Web namespace. Handlers are somewhat analogous to Internet Server Application Programming Interface (ISAPI) extensions. here with I will explain how to extend the functionality of web server by using Http handlers and How to protect files using Http handlers. Methods in Http Handler The following are the methods in Http Handlers. Method Name Description ProcessRequest Used to call Http Requests. IsReusable To check the reusability of same instance handler with a new request of same type Configuring HTTP Handlers The configuration section handler is responsible for mapping incoming URLs to the IHttpHandler or IHttpHandlerFactory class. It can be declared at the computer, site, or application level. Subdirectories inherit these settings. Administrators use the tag directive to configure the section. directives are interpreted and processed in a top-down sequential order. Use the following syntax for the section handler: Code: <httpHandlers> <add verb="[verb list]" path="[path/wildcard]" type="[COM+ Class], [Assembly]" validate="[true/false]" /> <remove verb="[verb list]" path="[path/wildcard]" /> <clear /> </httpHandlers> To create an HTTP handler, you must implement the IHttpHandler interface. The IHttpHandler interface has one method and one property with the following signatures: Code: void ProcessRequest(HttpContext);
bool IsReusable {get;} By customizing http handlers, new functionalities can be added to Web Server. Files with new extensions like .text for a text file can be handled by Web Server by using http handlers. The future of customization can lead to hosting .jsp pages in IIS by finding adequate ISAPI extensions. The following steps are involved to create customized http handler: 1. Create a C# class library as “Examplehandler” 2. Name class as “Handlerclass.cs” Code: using System;
using System.Web;
using System.Web.SessionState;
namespace ExampleHandler
{
/// <summary>
/// Summary description for Examplehandler.
/// </summary>
public class Handlerclass : IHttpHandler
{
public Handlerclass()
{
//
// TODO: Add constructor logic here
//
}
#region Implementation of IHttpHandler
public void ProcessRequest(System.Web.HttpContext context)
{
HttpResponse objResponse = context.Response ;
HttpSessionState objSession = context.Session ;
objResponse.Write("<html><body><h1>Hello World from Handler") ;
objResponse.Write("</body></html>") ;
}
public bool IsReusable
{
get
{
return true;
}
}
#endregion
}
} Compile it and place it in the bin directory of TestApp project. Step 2 Register this handler by adding the following text in the web.config file: Code: <httpHandlers> <add verb="*" path="*.text" type=" ExampleHandler.Handlerclass, ExampleHandler "/> </httpHandlers> Go to Internet Information Services and select Default Web Site. Right Click and Select Properties. Select Home Directory and click on Configuration. Click on Add and give executable path and new extension and click OK. Close IIS and Run TestApp website by using the URL http://localhost/Testapp/hello.text HttpForbiddenHandler The sensitive files can be protected by Http Forbidden Handler. The Database driven web sites using MS Access, the .mdb file has to be protected. To protect the .mdb files, we must follow the two steps given below: 1. Map .mdb file in IIS 2. Register the file extension in web.config with HttpForbiddenHandler. In the Web.Config file, Add this Http handler section: Code: <httpHandlers> <add verb="*" path="*.mdb" type="System.Web.HttpForbiddenHandler"/> </httpHandlers> The Http Handlers are often useful when the services provided by the high-level page framework abstraction are not required for processing the HTTP request. Common uses of handlers include filters and CGI-like applications, especially those that return binary data.
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting keyboard response in php code | sip | PHP Programming | 1 | 01-07-2008 01:22 AM |
| WebException, HTTP 404 ,the request failed with HTTP status 404: Not Found | kingmaker | ASP and ASP.NET Programming | 2 | 08-29-2007 06:19 AM |
| If I use Response.Redirect in try block exception occurred in c#, Why? | kingmaker | C# Programming | 1 | 07-19-2007 04:51 AM |
| How can I invoke another program or command and trap its output in C? | Sabari | C and C++ Programming | 1 | 07-17-2007 04:01 AM |
| Performance on Web Response Times | Jeyaseelansarc | PHP Programming | 0 | 05-18-2007 10:37 PM |