473,888 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with asynchronous HttpWebRequest

Hi,

I'm having a problem with asynchronous HttpWebRequest. It's a simple
http client-server. For most of my users it works fine. However, some
of them get the exception:

System.Net.WebE xception: Unable to connect to the remote server --->
System.Net.Sock ets.SocketExcep tion: The attempted operation is not
supported for the type of object referenced
at System.Net.Sock ets.Socket.get_ ConnectEx()
at System.Net.Sock ets.Socket.Begi nConnectEx(EndP oint remoteEP,
Boolean flowContext, AsyncCallback callback, Object state)
at System.Net.Sock ets.Socket.Unsa feBeginConnect( EndPoint remoteEP,
AsyncCallback callback, Object state)
at System.Net.Serv icePoint.Connec tSocketInternal (Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketSt ate state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.Http WebRequest.EndG etResponse(IAsy ncResult
asyncResult)

My code is:

Uri url = new Uri(getURI());
m_request = (HttpWebRequest )WebRequest.Cre ate(url);
m_request.Crede ntials = CredentialCache .DefaultCredent ials;
m_request.UserA gent = getUserAgent();
m_request.Begin GetResponse(new AsyncCallback(P rocessResponse) , null);

and then:

private void ProcessResponse (IAsyncResult asynchronousRes ult) {
HttpWebResponse response =
(HttpWebRespons e)m_request.End GetResponse(asy nchronousResult );
Stream stream = response.GetRes ponseStream();
....
}

This is so weird.
Any ideas ?

Thanks!

Feb 7 '06 #1
1 3374
Is it a normal "http://server/" address?

Are you using IPSEC?

It's possible the tcp/ip registry settings could be corrupted...
http://support.microsoft.com/kb/811259
Hi,

I'm having a problem with asynchronous HttpWebRequest. It's a simple
http client-server. For most of my users it works fine. However, some
of them get the exception:

System.Net.WebE xception: Unable to connect to the remote server --->
System.Net.Sock ets.SocketExcep tion: The attempted operation is not
supported for the type of object referenced
at System.Net.Sock ets.Socket.get_ ConnectEx()
at System.Net.Sock ets.Socket.Begi nConnectEx(EndP oint remoteEP,
Boolean flowContext, AsyncCallback callback, Object state)
at System.Net.Sock ets.Socket.Unsa feBeginConnect( EndPoint remoteEP,
AsyncCallback callback, Object state)
at System.Net.Serv icePoint.Connec tSocketInternal (Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketSt ate state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.Http WebRequest.EndG etResponse(IAsy ncResult
asyncResult)
My code is:

Uri url = new Uri(getURI());
m_request = (HttpWebRequest )WebRequest.Cre ate(url);
m_request.Crede ntials = CredentialCache .DefaultCredent ials;
m_request.UserA gent = getUserAgent();
m_request.Begin GetResponse(new AsyncCallback(P rocessResponse) , null);
and then:

private void ProcessResponse (IAsyncResult asynchronousRes ult) {
HttpWebResponse response =
(HttpWebRespons e)m_request.End GetResponse(asy nchronousResult );
Stream stream = response.GetRes ponseStream();
...
}
This is so weird.
Any ideas ?
Thanks!

Feb 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9476
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() implementation. All I need to do is to modify line with "to change". My client uses derrived HttpWebRequest. I tried to implement new class MyHttpWebRequest and override GetResponse for it, but how can I create instance of this class. In .Net there...
1
2881
by: Sojwal Chitnis | last post by:
Hi, We have a asp.net web application in which we are making HTTP requests to a remote web server (CGI) & get response in form of XML data. We are using HttpWebRequest object to post the request. In case of concurrent users using our web application: 1. On a page if there are multiple such HTTP requests, will IIS process the requests
4
1500
by: Dave | last post by:
I've have several webrequests being called consecutively from an .aspx that return XML from sources outside the company. When the page runs it can take anywhere between 30-60 seconds. I heard about making webrequests asynchronosly and found: http://samples.gotdotnet.com/quickstart/howto/doc/ASPXNet/GETAsync.aspx I modified the code to add a couple requests right after each other as listed below.
0
1112
by: davidpenty | last post by:
Hi there, I am having some problems with a multi-threaded asp.net seach page. My search page sends off four asynchronous http requests to four search engines then waits for the results to come back (in xml) The searches are just URLs with querystrings. Each request sets a boolean to true when it has got a reply from the search engine. I have declare the booleans as 'volatile'.
2
2224
by: Giulio Petrucci | last post by:
Hi everytbody, I'm experiencing some problems trying to asynchronously read data from a Socket object. What I do now is: 1) call th BeginReceive(...) method on the Socket object; 2) within the asynchronous callback method, call the EndReceive method, getting the number of read bytes (stored in a variable called rb) 3) if (rb>0) I can suppose there are still some other bytes to be read, so call again the BeginReceive(...) method, else...
4
4555
by: MaxMax | last post by:
I'm using HttpWebRequest. It seems that all the callback called from HttpWebRequest are in another thread (not in the "original" thread). Now my problem is that the "original" thread is the thread that maintains the interface (the forms). I want to signal from the "worker" thread to the main thread that I've finished downloading the page. How should I do? I can't simply wait for the end of the thread as in this...
0
5157
by: Morgan Cheng | last post by:
In the doc http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.timeout.aspx, it reads, "A Domain Name System (DNS) query may take up to 15 seconds to return or time out. If your request contains a host name that requires resolution and you set Timeout to a value less than 15 seconds, it may take 15 seconds or more before a WebException is thrown to indicate a timeout on your request." The words doesn't appear in .Net 1.1...
0
254
by: APA | last post by:
I've seen the MS sample async web request pattern and I ask is it really async if it is using a ManualResetEvent and setting WaitOne()? The ManualResetEvent object is being declared as a static variable so isn't it causing problems with other threads that may be using the same class to execute the async web request? If I remove the ManualResetEvent object will it be truly asynchronous and will I be losing something? Also, in my app the web...
1
1892
by: sindhurasingeetham | last post by:
Hi, I'm new to coding in .NET. I am trying to do an asynchronous call in my code using httpwebrequest. This code works perfectly fine on one server, but does not work on another. The main flow works on the new server, but it somehow does not do the asynchronous calling part. I'm unable to see the async part hitting IIS (from the IIS logs) as well. I have compared the IIS settings on both the servers and they are the same. The settings on both...
0
9961
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10886
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9597
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.