.NET Framework Bookmark and Share   
 index > .NET Framework Networking and Communication > Getting Error 503 on proxy with non-default credentials
 

Getting Error 503 on proxy with non-default credentials

Hello everybody!

While my C# program is working fine on other systems, one of its users who uses a proxy server is consistently getting ERROR 503 (Server not available) when theprogramtries to access some URLS (e.g.http://www.book***.com/skysales/Search.aspx?) via HttpWebRequest and GET method, while the same link would open successfully in IE or any other browser upon login with username and password. Yet other links (such ashttp://***.com/en/book/index.asp?) open successfully with my program on the same user's machine.

Here is how I do it:

HttpWebRequest request =      
    (HttpWebRequest)WebRequest.Create(Url);
request.Method = "GET";

IWebProxy proxy = null;

int i = args.IndexOf("-proxy");
if (i != -1)
{
    if (args[i+1] == "default")
    {
       proxy = WebRequest.GetSystemWebProxy();
    }
    else
    {
        // Create new Proxy
        // e.g. myproxy, 8080
        Command.proxy = new WebProxy(args[i+1] + ":" + args[i+2]);
        // Set Credentials
        // e.g. "user", "password"
        Command.proxy.Credentials = new NetworkCredential(args[i+3], args[i+4]);
    }
}

if (proxy != null)
{
      request.Proxy = proxy;
}

WebResponse  response = webRequest.GetResponse();



Somewhere in the code, I also set request's headers to:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-gb 
Accept-Encoding: gzip 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Connection: Keep-Alive 

The user starts the program with "-proxy hisproxy.com 80 some_username some_password" parameters.

Previously, the user was starting the program without any arguments (so no proxy), and every Url at that time resulted inERROR 407 (proxy authentication request). And now some Urls work, but some don't.

Does anybody have an idea how to troubleshoot this?

Thanks a lot
Darko




Darko Pesikan
It is difficult to say what is going wrong, without logs. Ask your user to enable logging (see .config file at <a href="http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html">http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html</a> ) and then ask him to send you the log file.

The logfile will show whether the request from the client to the proxy succeeded or not.

What you need to know is whether the 503 is coming from the proxy, or from the destination server.
feroze
--
My blog
Feroze Daud
Hi feroze and thank you so much for your answer. Here is link to the relevant part of the user's log file: www.azuon.com/etc/log.txt. Hope this can help identify the problem.
Darko Pesikan
The error response has all the information...

System.Net.Sockets Verbose: 0 : [6024] 000001F0 : 3E 45 52 52 4F 52 3A 20-54 68 65 20 72 65 71 75 : >ERROR: The requ
System.Net.Sockets Verbose: 0 : [6024] 00000200 : 65 73 74 65 64 20 55 52-4C 20 63 6F 75 6C 64 20 : ested URL could
System.Net.Sockets Verbose: 0 : [6024] 00000210 : 6E 6F 74 20 62 65 20 72-65 74 72 69 65 76 65 64 : not be retrieved
System.Net.Sockets Verbose: 0 : [6024] 00000220 : 3C 2F 54 49 54 4C 45 3E-0A 3C 53 54 59 4C 45 20 : </TITLE>.<STYLE
System.Net.Sockets Verbose: 0 : [6024] 00000230 : 74 79 70 65 3D 22 74 65-78 74 2F 63 73 73 22 3E : type="text/css">
System.Net.Sockets Verbose: 0 : [6024] 00000240 : 3C 21 2D 2D 42 4F 44 59-7B 62 61 63 6B 67 72 6F : <!--BODY{backgro
System.Net.Sockets Verbose: 0 : [6024] 00000250 : 75 6E 64 2D 63 6F 6C 6F-72 3A 23 66 66 66 66 66 : und-color:#fffff
System.Net.Sockets Verbose: 0 : [6024] 00000260 : 66 3B 66 6F 6E 74 2D 66-61 6D 69 6C 79 3A 76 65 : f;font-family:ve
System.Net.Sockets Verbose: 0 : [6024] 00000270 : 72 64 61 6E 61 2C 73 61-6E 73 2D 73 65 72 69 66 : rdana,sans-serif
System.Net.Sockets Verbose: 0 : [6024] 00000280 : 7D 50 52 45 7B 66 6F 6E-74 2D 66 61 6D 69 6C 79 : }PRE{font-family
System.Net.Sockets Verbose: 0 : [6024] 00000290 : 3A 73 61 6E 73 2D 73 65-72 69 66 7D 2D 2D 3E 3C : :sans-serif}--><
System.Net.Sockets Verbose: 0 : [6024] 000002A0 : 2F 53 54 59 4C 45 3E 0A-3C 2F 48 45 41 44 3E 3C : /STYLE>.</HEAD><
System.Net.Sockets Verbose: 0 : [6024] 000002B0 : 42 4F 44 59 3E 0A 3C 48-31 3E 45 52 52 4F 52 3C : BODY>.<H1>ERROR<
System.Net.Sockets Verbose: 0 : [6024] 000002C0 : 2F 48 31 3E 0A 3C 48 32-3E 54 68 65 20 72 65 71 : /H1>.<H2>The req
System.Net.Sockets Verbose: 0 : [6024] 000002D0 : 75 65 73 74 65 64 20 55-52 4C 20 63 6F 75 6C 64 : uested URL could
System.Net.Sockets Verbose: 0 : [6024] 000002E0 : 20 6E 6F 74 20 62 65 20-72 65 74 72 69 65 76 65 : not be retrieve
System.Net.Sockets Verbose: 0 : [6024] 000002F0 : 64 3C 2F 48 32 3E 0A 3C-48 52 20 6E 6F 73 68 61 : d</H2>.<HR nosha
System.Net.Sockets Verbose: 0 : [6024] 00000300 : 64 65 20 73 69 7A 65 3D-22 31 70 78 22 3E 0A 3C : de size="1px">.<
System.Net.Sockets Verbose: 0 : [6024] 00000310 : 50 3E 0A 57 68 69 6C 65-20 74 72 79 69 6E 67 20 : P>.While trying
System.Net.Sockets Verbose: 0 : [6024] 00000320 : 74 6F 20 72 65 74 72 69-65 76 65 20 74 68 65 20 : to retrieve the
System.Net.Sockets Verbose: 0 : [6024] 00000330 : 55 52 4C 3A 0A 3C 41 20-48 52 45 46 3D 22 68 74 : URL:.<A HREF="ht
System.Net.Sockets Verbose: 0 : [6024] 00000340 : 74 70 3A 2F 2F 77 77 77-2E 62 6F 6F 6B 72 79 61 : tp://www.bookrya
System.Net.Sockets Verbose: 0 : [6024] 00000350 : 6E 61 69 72 2E 63 6F 6D-2F 73 6B 79 73 61 6C 65 : nair.com/skysale
System.Net.Sockets Verbose: 0 : [6024] 00000360 : 73 2F 53 65 61 72 63 68-2E 61 73 70 78 3F 22 3E : s/Search.aspx?">
System.Net.Sockets Verbose: 0 : [6024] 00000370 : 68 74 74 70 3A 2F 2F 77-77 77 2E 62 6F 6F 6B 72 : http://www.bookr
System.Net.Sockets Verbose: 0 : [6024] 00000380 : 79 61 6E 61 69 72 2E 63-6F 6D 2F 73 6B 79 73 61 : yanair.com/skysa
System.Net.Sockets Verbose: 0 : [6024] 00000390 : 6C 65 73 2F 53 65 61 72-63 68 2E 61 73 70 78 3F : les/Search.aspx?
System.Net.Sockets Verbose: 0 : [6024] 000003A0 : 3C 2F 41 3E 0A 3C 50 3E-0A 54 68 65 20 66 6F 6C : </A>.<P>.The fol
System.Net.Sockets Verbose: 0 : [6024] 000003B0 : 6C 6F 77 69 6E 67 20 65-72 72 6F 72 20 77 61 73 : lowing error was
System.Net.Sockets Verbose: 0 : [6024] 000003C0 : 20 65 6E 63 6F 75 6E 74-65 72 65 64 3A 0A 3C 55 : encountered:.<U
System.Net.Sockets Verbose: 0 : [6024] 000003D0 : 4C 3E 0A 3C 4C 49 3E 0A-3C 53 54 52 4F 4E 47 3E : L>.<LI>.<STRONG>
System.Net.Sockets Verbose: 0 : [6024] 000003E0 : 0A 5A 65 72 6F 20 53 69-7A 65 64 20 52 65 70 6C : .Zero Sized Repl
System.Net.Sockets Verbose: 0 : [6024] 000003F0 : 79 0A 3C 2F 53 54 52 4F-4E 47 3E 0A 3C 2F 55 4C : y.</STRONG>.</UL
The 503 is coming from the destination server, not the proxy.

I am seeing that you sent a request to a particular URL with a query string:

System.Net Verbose: 0 : [6024] HttpWebRequest#46153895::HttpWebRequest(http://www.book***.com/skysales/Search.aspx?#-1926415116)

However, the outgoing request did not have the query string params.

System.Net Information: 0 : [6024] Associating HttpWebRequest#46153895 with ConnectStream#60345850
System.Net Information: 0 : [6024] HttpWebRequest#46153895 - Request: GET http://www.book***.com/skysales/Search.aspx? HTTP/1.1

System.Net.Sockets Verbose: 0 : [6024] Socket#50920718::Send()
System.Net.Sockets Verbose: 0 : [6024] Data from Socket#50920718::Send
System.Net.Sockets Verbose: 0 : [6024] 00000000 : 47 45 54 20 68 74 74 70-3A 2F 2F 77 77 77 2E 62 : GET http://www.b
System.Net.Sockets Verbose: 0 : [6024] 00000010 : 6F 6F 6B 72 79 61 6E 61-69 72 2E 63 6F 6D 2F 73 : ook***.com/s
System.Net.Sockets Verbose: 0 : [6024] 00000020 : 6B 79 73 61 6C 65 73 2F-53 65 61 72 63 68 2E 61 : kysales/Search.a
System.Net.Sockets Verbose: 0 : [6024] 00000030 : 73 70 78 3F 20 48 54 54-50 2F 31 2E 31 0D 0A 55 : spx? HTTP/1.1..U


Can you get a logfile of a successful transaction, and compare the two to see what is diferent?
feroze
--
My blog
Feroze Daud
Hello and thanks for your reply! The outgoing request linkindeedcontains a ? at the end, but the link is not supposed to contain any string parameters. The ? is just an extra at the end and the link should be actually without it, but it should not hurt (does it??), because another successful request to a different server (see link in this message) does not have parameters either but contains a ?.

Here is a log file of a successful request: www.azuon.com/etc/success.log. I did not notice anything unusual, the log looks to me the same as the previous one. There must be something I constantly fail to see... Please help.

Darko




Darko Pesikan
Both these logs are for different cases. The failure case was for RyanAir. The success log was for easyjet.

In both the cases, it looks like the Squid proxy tried to contact the destination server. In the case of RyanAir, it failed.

When googling for "squid ERR_ZERO_SIZE_OBJECT" I found an entry:

http://www2.gr.squid-cache.org/mail-archive/squid-users/200608/0454.html

according to which it says that the server closed the connection before sending the response headers to the proxy.

So it looks like there might be connectivity issues between the squid proxy and the RyanAir servers.

Try retrying the request with a "cache-control: no-cache" header added to the HttpWebRequest.

If that doesnt work, I dont know what else to tell you. It looks like it is a network connectivity problem in the user's network, between the proxy server and the RyanAir servers.
feroze
--
My blog
  • Proposed As Answer byFeroze Daud Wednesday, September 23, 2009 1:59 PM
  •  
Feroze Daud

You can use google to search for other answers

Custom Search

More Threads

• How can i know whether any message has come to queue in MSMQ
• Detecting all active IPs in a network
• SocketException Unhandled - No connection could be made because the target machine actively refused it 127.0.0.1:2112
• Number of firewall is running in my Network??????
• Unmanaged code
• how to add a network place
• serial port asp.net
• Creating Web Application's CD Version
• .NET class or native API that supports the signature exchange for authenication
• Issue while checking-in and checking-out a file.