Problem with HttpWebRequest.

D

Dave R

Hi all,

I am using the HttpWebRequest/HttpWebResponse API in my application to post data
to a remote server.
The remote server is a Unix box (remoteserver.remotedomain.com).
But somehow I receive no response from the server.
If I use a server in my own domain and specify
WebRequest.Create("http://myserver:1200"); things work fine.
Even fully qualified name of my own localserver fetches no response i.e.
WebRequest.Create("http://myserver.mydomain.com:1200"); things do not work.


Here is the relevant code.

HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://remoteserver.remotedomain.com:1200");

request.Method = "POST" ;
request.ContentType = "application/vnd.wv.csp.wbxml";
request.ContentLength= Buffer.Length ;

WebProxy myProxy = WebProxy.GetDefaultProxy ();
request.Proxy = myProxy ;

Stream newStream = request.GetRequestStream(); newStream.Write (Buffer, 0,
Buffer.Length);

// Close the Stream object.
newStream.Close();

//****** CULPRIT LINE *********//
// The following call just blocks.
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();

// *********************** //
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream ();

/// ... so on

Am I missing on something ?

Best regards,
Dave
 
F

Feroze [MSFT]

IS your app blocking indefinitely, or just taking a long time ? Maybe your
server is outside of your lan, so webrequest might not succeed unless you go
through a proxy ?

If this is not the case, please give more details about your configuration.
can you do a GET request against the server using the fully qualified domain
name (FQDN)

--
Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
D

Dave R

Hi Feroze,

Thanks for the reply.
My applications blocks indefinitely till I get an Operation time out error.
Well you are correct in that my remote server is outside my LAN.
I use VPN to connect to it, so virtually the remote server is on my intranet.

I have tried to run my app. with and without setting the proxy.
Wioth both the application blocks :-(
This is the relevent code -
WebProxy myProxy = WebProxy.GetDefaultProxy ();
// request is an HttpWebRequest object.
request.Proxy = myProxy ;

IMO, I should not be setting the proxy because effectively server is in my
domain (am on VPN).
But somehow call just doesn't go through.

One intresting observation is that if I use Remote terminal Service client and
run my app from a remote NT box to connect to the remote server, all calls run
fine.
Am puzzled as to why it runs through remote NT box and not when I try it through
VPN.
I could also resolve "remoteserver.remotedomain.com" to aaa.bbb.ccc.ddd IP
address through Dns class while being on VPN.

Any thoughts?

Best regards,
Dave

P.S : I think it's some network issue but am confused beacuse I can resolve the
IP address of the remote server while being on VPN. Essentially API also might
be doing it.


Feroze said:
IS your app blocking indefinitely, or just taking a long time ? Maybe your
server is outside of your lan, so webrequest might not succeed unless you go
through a proxy ?

If this is not the case, please give more details about your configuration.
can you do a GET request against the server using the fully qualified domain
name (FQDN)

--
Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
F

Feroze [MSFT]

Hmm. If you are connected on the VPN, you should be able to get this to
work. Do you have access to a network sniffer ? Can you run a network
sniffer on your app to see what is happening ?

I am assuming you already tried hitting your site with a browser ?

--
Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top