?
Solved

Webrequest.GetResponse() Hangs after three or four times

Posted on 2004-08-05
13
Medium Priority
?
792 Views
Last Modified: 2013-12-27
Dear ALL

I am using visual studio 2003.

I use  this function for get the html file from web server .
----------------------------------------------
Public Shared Function GetResponseStringA(ByVal RemoteURL As String) As String

Dim StartTime As DateTime = DateTime.Now()
Dim DownloadContent As String
Dim objRequest As Net.WebRequest, objResponse As Net.WebResponse,
objStreamReceive As System.IO.Stream, objEncoding As
System.Text.Encoding, objStreamRead As System.IO.StreamReader

Try
    DownloadContent = ""
    objRequest = Net.WebRequest.Create(RemoteURL)
   
    objResponse = objRequest.GetResponse
    objStreamReceive = objResponse.GetResponseStream
    objEncoding = System.Text.Encoding.GetEncoding("utf-8")
    objStreamRead = New System.IO.StreamReader(objStreamReceive,
objEncoding)
    DownloadContent = objStreamRead.ReadToEnd()
   
    If Not objResponse Is Nothing Then
        objResponse.Close()
    End If
   
    Return DownloadContent
Catch ex As Exception
     msgbox(ex.message)
End Try

End Function
--------------------------------------------------------------

This function works finely for few times

After five or six times . It hangs on the line
           objResponse = objRequest.GetResponse.

How to fix that problem

Prakash
0
Comment
Question by:prakash_prk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
13 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11748803
could you define "hangs" ? does it hang indefinately or does it eventually come back with an exception ?

0
 
LVL 10

Author Comment

by:prakash_prk
ID: 11749838

It means that .

It waits for a long time  and throws a  timeout exception for all requests after three or four times.

At the time I check that request URL in IE .It works fine.

How to solve this error gregoryyoung

bye
Prakash


0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11749868
ok, so its timing out while IE still works ? what type of network are you running on ? wireless lan serial etc.
0
Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

 
LVL 10

Author Comment

by:prakash_prk
ID: 11749880

I am testing with my PPC 2002 Emulator.

My Network a simple LAN of ten Computers connected to a network switch.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11749888
well on the emulator i would put it as pretty likely that its the emulator causing it. You can only use an emulator for your most basic testing, a real device is absolutly needed.
0
 
LVL 10

Author Comment

by:prakash_prk
ID: 11749913

Thank you for giving a good idea  gregoryyoung . I don't think on that area.

I try to  check my code in a PPC device

Thank you very much
Prakash

0
 
LVL 10

Author Comment

by:prakash_prk
ID: 11792167

hi  gregoryyoung .

The error Continous my PPC Device also  gregoryyoung.

what I to do ??

bye
Prakash
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11794328
ok ... lets try to write a very simple program that only has a button and a hard coded call to yahoo.com .... do you get the same behavior ?
0
 
LVL 10

Author Comment

by:prakash_prk
ID: 11817681
Hi gregoryyoung

I found the solution ..

It is a simple mistake by myself.

I have one more function in my program named UploadFile() it uploads a file to server from PDA.
I didn't  call the close method of WebResponse,WebRequest,Stream objects in the UploadFile() . On this day I see this code and add close methods the code .
The web response in GetResponseString() works well.

There is no link between this two functions. both of them are resides in different Classes. Both of them uses different variables ??

What going wrong ???

0
 
LVL 10

Author Comment

by:prakash_prk
ID: 11828838

Hi gregoryyoung

Thank you for your good suggesstions.

reagrds
Prakash

0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11832233
they use the same underlying code in the framework ... it may have been that you were leaving open file handles ...
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11866635
Closed, 250 points refunded.
Netminder
Site Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question