Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows WCF client with internet proxy server showing error The server committed a protocol violation. Section=ResponseStatusLine

Tags:

c#

.net

windows

wcf

Our team trying to create a windows application(c#) to call a WCF service using internet proxy server

Showing exception "The server committed a protocol violation. Section=ResponseStatusLine" while calling WCF service

Please give suggestion to solve this problem/any other alternative solution

//Code for creating proxy
public static DevicesServiceClient CreateProxy()
{
  var proxy = new DevicesServiceClient("BasicHttpBinding_IDevicesService");

  BasicHttpBinding binding = new BasicHttpBinding();
  binding.Security.Mode = BasicHttpSecurityMode.None;
  binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
  binding.UseDefaultWebProxy = false;
  binding.ProxyAddress = new Uri(string.Format("http://{0}:{1}", "192.168.0.20","808"));
  proxy.Endpoint.Binding = binding;

  proxy.ClientCredentials.UserName.UserName = "Username";
  proxy.ClientCredentials.UserName.Password = "Password";
}

Server stack trace:

at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at DevicesService.IDevicesService.CheckNetworkConnection(String ipAddress)

My client side code in app.config alt text

My server side code in web.config alt text

like image 858
amexn Avatar asked Oct 01 '10 12:10

amexn


2 Answers

I haven't seen this exception before but I already had big problems to make proxy work this way. I don't know why but setting proxy address and use default proxy to false in BasicHttpBinding never worked for me. I always had to use default web proxy and set the URL there or create whole new custom binding and set proxy URL in http transport binding element.

like image 90
Ladislav Mrnka Avatar answered Nov 15 '22 00:11

Ladislav Mrnka


Try checking the headers returned by your proxy server. It looks like malformed/non standard headers cause this exception.

http://www.velocityreviews.com/forums/t302174-why-do-i-get-the-server-committed-a-protocol-violation.html

like image 40
ivymike Avatar answered Nov 14 '22 22:11

ivymike