473,405 Members | 2,445 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,405 software developers and data experts.

407 Proxy Authentication Required - Not using a Proxy

We have an application that is running fine on several of our customer’s
servers. However, one of our customers is having a problem running the
application. The application works on one of his Windows 2003 servers, but
not on the other one.

The application is a C++ .Net /clr Windows Service. It communicates with
our server by sending and receiving XML using the WebClient object. The
error they are receiving is “The remote server returned an error: (407) Proxy
Authentication Required”. But, our client swears that he is not going
through a proxy server.

To make things even more odd, if you reboot the server, the application
works for the first connection. The first connection can send and receive
data, but then all subsequent attempts fail with the proxy error.

The code is pretty basic:

Uri ^SourceUri = gcnew Uri(RequestUrl);
WebClient ^client = gcnew WebClient();
//----------create proxy server object -----------------------
NetworkCredential^ UserCreds = nullptr;
WebProxy^ proxyObject = nullptr;
//----------is user using a proxy-----------------------------
if (pConfig->UseProxyServer == true){
UserCreds = gcnew NetworkCredential( pConfig->ProxyUserName,
pConfig->ProxyPassword, pConfig->ProxyUserDomain );
proxyObject = gcnew WebProxy( String::Concat("http://",
pConfig->ProxyServerName, ":", pConfig->ProxyServerPort, "/") , true);
proxyObject->Credentials = UserCreds;
client->Proxy = proxyObject;
}else{
//-------------use default credentials-------------------------
client->UseDefaultCredentials = true;
}
//-------------------------------------------------------------
client->Headers->Add("Content-Type", "application/x-www-form-urlencoded;
charset=UTF-8");
array<Byte^byteArray = Encoding::UTF8->GetBytes(XmlDataToSend);
array<Byte^responseArray = client->UploadData(SourceUri->AbsoluteUri,
"POST", byteArray);

Any ideas why the code would work the first time, but then fail with a proxy
error on subsequent attempts? Are there any tests I can run to help debug
this problem? Any help would be greatly appreciated.


Aug 14 '07 #1
1 4969
Hi Gallan,

This issue should be a System.Net.WebClient programming problem and does
not have too much relation with C++/CLI language. Anyway, I will help you
on it.

Based on my experience, the error should be returned by the proxy server,
if the customer did not have proxy configured, this is really strange. Can
you ask the customer to check if there is any proxy setting in IE
Tools->Internet Options -Connections ->LAN settings? I suspect they may
get a proxy setting which they are unaware of.

Additionally, if they do no have proxy, why do you still explicitly pass
the proxy address and username/password through NetworkCredential and
WebProxy. If there is no proxy, you should specify empty proxy through
GlobalProxySelection.GetEmptyWebProxy method and use the
System.Net.CredentialCache.DefaultCredentials.

Finally, if you want to understand the details of the WebClient
communications, you may enable the System.Net log tracing. In the trace
log, you may examine whether your WebClient is communicating to any proxy.
Please refer to the 2 links below to enable the trace log:
"Enabling Network Tracing"
http://msdn2.microsoft.com/en-us/library/a6sbz1dx.aspx
"How to: Configure Network Tracing"
http://msdn2.microsoft.com/en-us/library/ty48b824.aspx

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 14 '07 #2

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

Similar topics

1
by: Mark Ferguson | last post by:
I've been trying to get a simple pycurl script working with an authenticating proxy, here is the code (with changes to protect the guilty!): from pycurl import * import StringIO b =...
4
by: Morten Snedker | last post by:
I'm trying to download a file. I've tried both using webclient and the httpWebRequest. Either way it returns a "407 proxy authentication required". The program is to be run externally, so...
3
by: Wild Wind | last post by:
Hello all, I apologise in advance for the long windedness of this post, but I feel that if I am going to get any solution to this problem, it is important that I present as much information...
2
by: rcp | last post by:
Hi all, I've read all posts from all existing threads and none of them worked to solve my problem, although its exactly the same. I'll try to explain my case and see if a kind soul could help me...
0
by: J Ames | last post by:
Please, if this is the incorrect forum for this question, let me know which forum is most appropriate. I want to make sure I get visibility with the proper gurus! I have a .NET console app that...
4
by: Boni | last post by:
I want consuming a webserivce trough a proxy. I use this code. myService s = new myService (); System.Net.WebProxy proxyObject = new System.Net.WebProxy("http://proxyhost:8080"); s.Proxy =...
7
by: chandru1782 | last post by:
Dear friends, I am trying to use CPAN for installing some perl modules. i am using a ubuntu system, which has internet connection through lan and authenticated proxy. when trying to install...
2
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
I'm researching what is the best way to create a generic WCF proxy wrapper that has the following requirements: 1. Remove the System.ServiceModel config section requirement for clients. We have...
2
by: krishnakrish | last post by:
Hi, My name is krishna. I am using asp.net 2.0 with C#. I amusing Windows XP professional as OS. When I post some data to an external web server I get the error as "The Remote server returned an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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...
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.