IT Community - Software Programming, Web Development and Technical Support

HTTP Web Response Exception - I cant able to trap.

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Mobile Software Development > Windows Mobile

Register FAQ Members List Calendar Mark Forums Read
  #21 (permalink)  
Old 08-30-2007, 10:02 AM
james james is offline
D-Web Trainee
 
Join Date: Aug 2007
Posts: 16
james is on a distinguished road
Default Re: HTTP Web Response Exception - I cant able to trap.

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!!!!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 08-30-2007, 10:04 AM
balaji2508 balaji2508 is offline
D-Web Trainee
 
Join Date: Aug 2007
Posts: 9
balaji2508 is on a distinguished road
Default Re: HTTP Web Response Exception - I cant able to trap.

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 08-30-2007, 10:09 AM
john john is offline
D-Web Trainee
 
Join Date: Aug 2007
Posts: 6
john is on a distinguished road
Default Re: HTTP Web Response Exception - I cant able to trap.

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24 (permalink)  
Old 08-30-2007, 10:10 AM
james james is offline
D-Web Trainee
 
Join Date: Aug 2007
Posts: 16
james is on a distinguished road
Default Re: HTTP Web Response Exception - I cant able to trap.

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25 (permalink)  
Old 08-30-2007, 10:11 AM
prasannavigneshr prasannavigneshr is offline
D-Web Incredible
 
Join Date: Feb 2007
Posts: 1,316
prasannavigneshr is on a distinguished road
Send a message via MSN to prasannavigneshr
Default Re: HTTP Web Response Exception - I cant able to trap.

Try to change HTTP proxy from HTTP 1.0 to 1.1 or vice versa.
__________________
Prasanna Vignesh
MCPD | Web Developer
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #26 (permalink)  
Old 08-30-2007, 10:17 AM
sandhya sandhya is offline
D-Web Trainee
 
Join Date: Aug 2007
Posts: 9
sandhya is on a distinguished road
Default Re: HTTP Web Response Exception - I cant able to trap.

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,
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27 (permalink)  
Old 09-19-2007, 07:17 AM
latchu latchu is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 21
latchu is on a distinguished road
Question Re: HTTP Web Response Exception - I cant able to trap.

Hi buddies....

How can we use HTTP Handlers in web application?

Is any idea?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28 (permalink)  
Old 09-19-2007, 07:28 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Smile Re: HTTP Web Response Exception - I cant able to trap.

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>
Creating HTTP Handlers

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;}
Customized Http Handler

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>
Step 3
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>
Conclusion

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!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting keyboard response in php code sip PHP Programming 1 01-07-2008 12:22 AM
WebException, HTTP 404 ,the request failed with HTTP status 404: Not Found kingmaker ASP and ASP.NET Programming 2 08-29-2007 05:19 AM
If I use Response.Redirect in try block exception occurred in c#, Why? kingmaker C# Programming 1 07-19-2007 03: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 03:01 AM
Performance on Web Response Times Jeyaseelansarc PHP Programming 0 05-18-2007 09:37 PM


All times are GMT -7. The time now is 02:58 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0