Can not use HttpWebRequest for localhost

S

Sergey Shcherbakov

Hello, everybody.

I am experiencing the following problem.
Environment: Visual Studio 2005, .NET CF2 SP2, Windows Mobile 5.0,
Fujitsu-Siemens LOOX n560.

I can not get any response using HttpWebRequest on PDA if the locally
running server is requested AND PDA is not connected to any LAN.

Request to the locally running server (server running on PDA)

HttpWebRequest req = (HttpWebRequest)
WebRequest.Create("http://localhost/");
// or "http://127.0.0.1/"
req.GetResponse();

fails with WebException with message "Can not establish connection to
network" only in case when there is no available network connection (for
instance WLAN is down and device is not in cradle). As soon as a network
connection is established the same call to GetResponse() works.

Pocket IE shows response from the local server without any problems
independently from the state of the device network connection.

Moreover, when there is no locally running server at all, a call to
HttpWebResponse.GetResponse():

- IF the network connection is present and available on PDA,
throws WebException "Can not establish connection to the remote server"
The InnerException != null and contains socket error code 10061.

- IF the network connection IS NOT available on PDA,
throws WebException "Can not establish connection to network"
InnerException == null

(StackTrace in both cases shows error in HttpWebRequest.finishGetResponse()
method)

Thus, two different errors.

I can run the same binary code on a desktop PC. In this case in both
situations the generated errors are the same: "Can not establish connection
to remote server".

Should these two errors be the same in case of connection attempt to the
local address?
What causes the second error to be different and is it possible to fix this?

This issue affects client SOAP calls using SoapHttpClientProtocol too. It is
not possible to call a locally running web service when there is no network
connection.

Is this a .NET CF2 bug?

Please help me!
 
T

Tim Van Wassenhove

Sergey Shcherbakov schreef:
I can not get any response using HttpWebRequest on PDA if the locally
running server is requested AND PDA is not connected to any LAN.

You could install a 'loopback adapter' so that a route to
127.0.0.1/localhost always exists...
 
S

Sergey Shcherbakov

"Tim Van Wassenhove" <[email protected]> ???????/???????? ? ????????
?????????: news: said:
Sergey Shcherbakov schreef:

You could install a 'loopback adapter' so that a route to
127.0.0.1/localhost always exists...

Thank you Tim!

That's probably what I need.

I have heard some loopback adapter exists for desktop OSes.

Could you give me a hint where can I get such adapter for Windows Mobile
5.0?
 
S

Sergey Shcherbakov

Sergey Shcherbakov schreef:
I'm not familiar with Windows Mobile, but i presume that
you need?



No. Unfortunately, this is the procedure how to install Microsoft Loopback
Adapter on Windows XP and Windows 2000 desktop OSes. I have been searching
the internet and I don't think that there is one for Windows Mobile.

I need to connect two application both running on Windows Mobile PDA. And it
IS possible by disconnected network using Sockets and/or TcpClient class. So
I don't think that loopback adapter would help.

The HttpWebRequest class is the one who does not work. It is being used by
..NET SOAP proxy classes as well, thus web service requests won't work when
no network connection exists.

Do you know how to submit this bug to Microsoft?
 
P

Paul G. Tobey [eMVP]

Have you tried connecting to that local IP address, 127.0.0.1, rather than
"localhost"?

Paul T.
 
S

Sergey Shcherbakov

Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
P

Paul G. Tobey [eMVP]

I'll see if I can come up with anything...

Paul T.

Sergey Shcherbakov said:
Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
Have you tried connecting to that local IP address, 127.0.0.1, rather
than "localhost"?

Paul T.
 
S

Sergey Shcherbakov

Thank you very much.
I would very appreciate any feedback from you.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
I'll see if I can come up with anything...

Paul T.

Sergey Shcherbakov said:
Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
Have you tried connecting to that local IP address, 127.0.0.1, rather
than "localhost"?

Paul T.

Sergey Shcherbakov schreef:

Could you give me a hint where can I get such adapter for Windows
Mobile

5.0?



I'm not familiar with Windows Mobile, but i presume that

http://msdn2.microsoft.com/en-us/library/ms928163.aspx contains the
info

you need?





No. Unfortunately, this is the procedure how to install Microsoft
Loopback Adapter on Windows XP and Windows 2000 desktop OSes. I have
been searching the internet and I don't think that there is one for
Windows Mobile.

I need to connect two application both running on Windows Mobile PDA.
And it IS possible by disconnected network using Sockets and/or
TcpClient class. So I don't think that loopback adapter would help.

The HttpWebRequest class is the one who does not work. It is being used
by .NET SOAP proxy classes as well, thus web service requests won't
work when no network connection exists.

Do you know how to submit this bug to Microsoft?
 
P

Paul G. Tobey [eMVP]

Yes, it does seem to need some sort of a network connection to recognize
that any network activity. That's probably as-designed, but I guess that
you could try reporting a bug via your support contract or for VS2005...

Paul T.

Sergey Shcherbakov said:
Thank you very much.
I would very appreciate any feedback from you.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
I'll see if I can come up with anything...

Paul T.

Sergey Shcherbakov said:
Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message Have you tried connecting to that local IP address, 127.0.0.1, rather
than "localhost"?

Paul T.

Sergey Shcherbakov schreef:

Could you give me a hint where can I get such adapter for Windows
Mobile

5.0?



I'm not familiar with Windows Mobile, but i presume that

http://msdn2.microsoft.com/en-us/library/ms928163.aspx contains the
info

you need?





No. Unfortunately, this is the procedure how to install Microsoft
Loopback Adapter on Windows XP and Windows 2000 desktop OSes. I have
been searching the internet and I don't think that there is one for
Windows Mobile.

I need to connect two application both running on Windows Mobile PDA.
And it IS possible by disconnected network using Sockets and/or
TcpClient class. So I don't think that loopback adapter would help.

The HttpWebRequest class is the one who does not work. It is being
used by .NET SOAP proxy classes as well, thus web service requests
won't work when no network connection exists.

Do you know how to submit this bug to Microsoft?
 
S

Sergey Shcherbakov

Thank you very much for the answer. I'll try to submit this issue.
Although it is very pity, that there is no workaround for that. (I am
writing simple proxy application for web service calls)

One more quick question:
Am I understanding right that you were checking HttpWebRequest (and probably
subsequent System.Net.Connection) class behavior?
I have tested my server using TcpClient and Socket classes and the
connection between processes works perfect even when there is no LAN
connection available.

Sincerely,
Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
Yes, it does seem to need some sort of a network connection to recognize
that any network activity. That's probably as-designed, but I guess that
you could try reporting a bug via your support contract or for VS2005...

Paul T.

Sergey Shcherbakov said:
Thank you very much.
I would very appreciate any feedback from you.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:%[email protected]...
I'll see if I can come up with anything...

Paul T.

Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message Have you tried connecting to that local IP address, 127.0.0.1, rather
than "localhost"?

Paul T.

Sergey Shcherbakov schreef:

Could you give me a hint where can I get such adapter for Windows
Mobile

5.0?



I'm not familiar with Windows Mobile, but i presume that

http://msdn2.microsoft.com/en-us/library/ms928163.aspx contains the
info

you need?





No. Unfortunately, this is the procedure how to install Microsoft
Loopback Adapter on Windows XP and Windows 2000 desktop OSes. I have
been searching the internet and I don't think that there is one for
Windows Mobile.

I need to connect two application both running on Windows Mobile PDA.
And it IS possible by disconnected network using Sockets and/or
TcpClient class. So I don't think that loopback adapter would help.

The HttpWebRequest class is the one who does not work. It is being
used by .NET SOAP proxy classes as well, thus web service requests
won't work when no network connection exists.

Do you know how to submit this bug to Microsoft?
 
P

Paul G. Tobey [eMVP]

I've done straight socket connections many times before with no network
connected, so, yes, I'm just using the HttpWebRequest class. It's clearly
trying to establish a connection with Connection Manager before it makes the
connection (since my WM5 device is a phone, you can see it making a
connection to the GPRS network when the code runs), and then failing to make
the connection. I guess, come to think of it, you might fool around a bit
with the Connection Manager settings (Work vs. The Internet, etc.) and see
if there's something to be discovered there.

Paul T.

Sergey Shcherbakov said:
Thank you very much for the answer. I'll try to submit this issue.
Although it is very pity, that there is no workaround for that. (I am
writing simple proxy application for web service calls)

One more quick question:
Am I understanding right that you were checking HttpWebRequest (and
probably subsequent System.Net.Connection) class behavior?
I have tested my server using TcpClient and Socket classes and the
connection between processes works perfect even when there is no LAN
connection available.

Sincerely,
Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
Yes, it does seem to need some sort of a network connection to recognize
that any network activity. That's probably as-designed, but I guess that
you could try reporting a bug via your support contract or for VS2005...

Paul T.

Sergey Shcherbakov said:
Thank you very much.
I would very appreciate any feedback from you.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
I'll see if I can come up with anything...

Paul T.

Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Have you tried connecting to that local IP address, 127.0.0.1, rather
than "localhost"?

Paul T.

Sergey Shcherbakov schreef:

Could you give me a hint where can I get such adapter for Windows
Mobile

5.0?



I'm not familiar with Windows Mobile, but i presume that

http://msdn2.microsoft.com/en-us/library/ms928163.aspx contains the
info

you need?





No. Unfortunately, this is the procedure how to install Microsoft
Loopback Adapter on Windows XP and Windows 2000 desktop OSes. I have
been searching the internet and I don't think that there is one for
Windows Mobile.

I need to connect two application both running on Windows Mobile
PDA. And it IS possible by disconnected network using Sockets and/or
TcpClient class. So I don't think that loopback adapter would help.

The HttpWebRequest class is the one who does not work. It is being
used by .NET SOAP proxy classes as well, thus web service requests
won't work when no network connection exists.

Do you know how to submit this bug to Microsoft?
 
G

Guest

Thank you.
I have already tried to change type of connection in Connection Manager. So
far without success.

Paul G. Tobey said:
I've done straight socket connections many times before with no network
connected, so, yes, I'm just using the HttpWebRequest class. It's clearly
trying to establish a connection with Connection Manager before it makes the
connection (since my WM5 device is a phone, you can see it making a
connection to the GPRS network when the code runs), and then failing to make
the connection. I guess, come to think of it, you might fool around a bit
with the Connection Manager settings (Work vs. The Internet, etc.) and see
if there's something to be discovered there.

Paul T.

Sergey Shcherbakov said:
Thank you very much for the answer. I'll try to submit this issue.
Although it is very pity, that there is no workaround for that. (I am
writing simple proxy application for web service calls)

One more quick question:
Am I understanding right that you were checking HttpWebRequest (and
probably subsequent System.Net.Connection) class behavior?
I have tested my server using TcpClient and Socket classes and the
connection between processes works perfect even when there is no LAN
connection available.

Sincerely,
Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:%[email protected]...
Yes, it does seem to need some sort of a network connection to recognize
that any network activity. That's probably as-designed, but I guess that
you could try reporting a bug via your support contract or for VS2005...

Paul T.

Thank you very much.
I would very appreciate any feedback from you.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
I'll see if I can come up with anything...

Paul T.

Yes, of course.
It makes exactly no difference.

Sergey.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
Have you tried connecting to that local IP address, 127.0.0.1, rather
than "localhost"?

Paul T.

Sergey Shcherbakov schreef:

Could you give me a hint where can I get such adapter for Windows
Mobile

5.0?



I'm not familiar with Windows Mobile, but i presume that

http://msdn2.microsoft.com/en-us/library/ms928163.aspx contains the
info

you need?





No. Unfortunately, this is the procedure how to install Microsoft
Loopback Adapter on Windows XP and Windows 2000 desktop OSes. I have
been searching the internet and I don't think that there is one for
Windows Mobile.

I need to connect two application both running on Windows Mobile
PDA. And it IS possible by disconnected network using Sockets and/or
TcpClient class. So I don't think that loopback adapter would help.

The HttpWebRequest class is the one who does not work. It is being
used by .NET SOAP proxy classes as well, thus web service requests
won't work when no network connection exists.

Do you know how to submit this bug to Microsoft?
 

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