G
Guest
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.
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.