473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

i have problem with GetResponse Method

minofino
Hello,

I am Beginner in VB.NET
So tell me why I cannot make more than 2 Requests in VB.NET
In the Same Time.

for Example : If you have a Form with one Button, Study this code in
Button Click Event.

Expand|Select|Wrap|Line Numbers
  1. '====================================================
  2.         Dim Url(2) As String
  3.         Url(0) = "................"          ' First Url Put Any Url Instead points
  4.         Url(1) = "................"          ' Second Url Put Any Url Instead points
  5.         Url(2) = "................"          ' Third Url Put Any Url Instead points
  6.  
  7.         Dim Wq(2) As HttpWebRequest
  8.         Dim Wp(2) As HttpWebResponse
  9.  
  10.         For I As Byte = 0 To 2
  11.           Wq(I) = WebRequest.Create(Url(I))
  12.           Wq(I).Timeout = 10000
  13.           Try
  14.               Wp(I) = Wq(I).GetResponse
  15.               Text = "Url " + Cstr(I) + " is OK"
  16.           Catch exp As WebException
  17.               Text = "Url " + Cstr(I) + " is " + exp.Status.ToString
  18.           End Try
  19.         Next I
  20. '====================================================
  21.  
Why the Third Url cannot Response and throw Exception "TimeOut" ?
Please Help me... THANKS.
Apr 12 '08 #1
5 1815
vanc
211 Expert 100+
Hello,

I am Beginner in VB.NET
So tell me why I cannot make more than 2 Requests in VB.NET
In the Same Time.

for Example : If you have a Form with one Button, Study this code in
Button Click Event.

Expand|Select|Wrap|Line Numbers
  1. '====================================================
  2.         Dim Url(2) As String
  3.         Url(0) = "................"          ' First Url Put Any Url Instead points
  4.         Url(1) = "................"          ' Second Url Put Any Url Instead points
  5.         Url(2) = "................"          ' Third Url Put Any Url Instead points
  6.  
  7.         Dim Wq(2) As HttpWebRequest
  8.         Dim Wp(2) As HttpWebResponse
  9.  
  10.         For I As Byte = 0 To 2
  11.           Wq(I) = WebRequest.Create(Url(I))
  12.           Wq(I).Timeout = 10000
  13.           Try
  14.               Wp(I) = Wq(I).GetResponse
  15.               Text = "Url " + Cstr(I) + " is OK"
  16.           Catch exp As WebException
  17.               Text = "Url " + Cstr(I) + " is " + exp.Status.ToString
  18.           End Try
  19.         Next I
  20. '====================================================
  21.  
Why the Third Url cannot Response and throw Exception "TimeOut" ?
Please Help me... THANKS.
Because the Third Url does not exist. You declared only 2 url variables and call the third url?!!!
Dim url(2) As String --> url(0) and url(1)
Cheers.
Apr 16 '08 #2
Hello Dear thanks for replying

But there is not a problem with Url array because index start with zero value
So i declared string array contains 3 urls from 0 to 2.
Replace Dim Url(2) .. with Dim Url(3) for example not diffrent and the
Problem still presents.

I searched the Net and found some problems like mine and the this problem happen :

beacauses the programmer can Declare one instance for httpwebrequest class and reuses it many times.

OR Declare the instance(means Variable) in Custom Class which Programmer
Create it and Declare many instance of that Custom Class.

But I cannot understand these 2 solution , Please help me.
Apr 16 '08 #3
vanc
211 Expert 100+
I don't see any problem when you fixed the upper bound of URL array. I don't do VB.NET so I converted your code into C# and changed a bit to make it run. Here is the code
Expand|Select|Wrap|Line Numbers
  1. string[] Url = new string[3];
  2.         Url[0] = "http://www.google.com";        
  3.         Url[1] = "http://www.yahoo.com";        
  4.         Url[2] = "http://www.bytes.com";       
  5.  
  6.         WebRequest[] Wq = new WebRequest[3];
  7.         WebResponse[] Wp = new WebResponse[3];
  8.  
  9.         for (byte i = 0; i<= 2; i++)
  10.         {
  11.             Wq[i] = WebRequest.Create(Url[i]);
  12.             Wq[i].Timeout = 10000;
  13.  
  14.             try
  15.             {
  16.                 Wp[i] = Wq[i].GetResponse();
  17.                 Response.Write("Url " + i.ToString() + " is OK");
  18.             }
  19.             catch (WebException exp)
  20.             {
  21.                 Response.Write("Url " + i.ToString() + " is " + exp.Status.ToString());
  22.             }
  23.         }
  24.  
Be noticed that I used the WebResponse and WebRequest classes, not HttpWebResponse and Request. Those three Urls all response correctly. Check your code again and give me some feedbacks. Cheers.
Apr 18 '08 #4
Curtis Rutland
3,256 Expert 2GB
I copied your code exactly, except for declaring Text as a string. I used these three urls:
http://www.google.com
http://www.engadget.com
http://bytes.com
And everything worked fine. The problem could be specifically with your third url. Make sure that you have access to the url from the server, and make sure that the user profile that the server uses can be authenticated on the site that the third url points to. If the site requires authentication, the user that ASP.NET uses may not have access.

Try your own code with these other urls and see what happens.
Apr 18 '08 #5
Hello, thanks again for replying
You are right threre is a problem with the Urls which i use to test my code
So i wrote These Urls to Study them :

Url(0) = "http://get.games.yahoo.com/dnld_handler;_ylt=
Ao9no6nbCm_kT9D_UzF1fHd0v8sh?gamekey=doggiedash"

Url(1) = "http://get.games.yahoo.com/dnld_handler?gamekey=
bigcityadventuresydney"

Url(2) = "http://get.games.yahoo.com/dnld_handler?gamekey=supple"

When I Changed the Order of Urls By Changing index of Array Items it gives
me the same result.

Infact, the Result "Ok" or "TimeOut" is happening in random way.
The error "TimeOut" most happen in Urls point to big files or slowly Urls.

When I made Array of 20 light Urls which point to very small files or html files
Like your Example "yahoo", "google" and "bytes" sites the urls must be "OK"

Please Study my Urls and Test Others Urls point to big files or slowly Urls.

At Last, I need to solve that problem very much beacuse I am devolping :
A Download Manager Program.

I am waiting for your help Thanks.
Apr 18 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Darryl | last post by:
I'm trying to use the HttpWebRequest class to retrieve XML generated by a jsp page, but an 'The remote server returned an error: (500) Internal Server Error' exception is thrown when I call the...
1
by: James | last post by:
Hi, I am new to .NET framework. I am trying to get data from the third party web application using WebHTTPRequest and Response class. I am getting TimeOut exception at GetResponse Method.. ...
4
by: R Reyes | last post by:
I am trying to code a file uploader (for forum/email attachments) from the client computer to a remote web server via the PUT method (since POST is not allowed ). However, the upload works ONLY...
2
by: news.microsoft.com | last post by:
Hello I try to implement "retry" if connection to web ends with "time out". I want to give a chance to prolong waiting for response. The following code is taken from WebRequest.GetResponse()...
5
by: japslam japslam via DotNetMonster.com | last post by:
Hi all, I have problem when I use HttpWebRequest and take long time to call to my service server. If at that time there are many request comes in semultaneous, I will get this exception ...
3
by: Taner Özyürekoglu | last post by:
I have an error below. is there any idea about it. Dim Req As HttpWebRequest = WebRequest.Create("https://certification.authorize.net/gateway/transact.dll?" & postdata) Response.Write("3")...
2
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response....
4
by: Savas Ates | last post by:
I have a vb.net web application. I want to post some variables to another web page and take some values back and process them. This is codes in my target url. I should post "langpair" cariable...
5
by: bg | last post by:
Hi all. I 'm trying to automate some of my workflow, by doing some programmatic "POST"s to an internal webserver via HttpWebRequest. The Code is your usual straight forward type of thing. ...
0
by: Petri | last post by:
Hi, I'm porting my App from .NET 1.1 to .NET 2.0, and I encountered a really weird problem. I hope some of you could help... I have a function that downloads an XML file from a web server to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.