"Keep-Alive and Close may not be set using this property"

So I'm getting the above exception when using an

IRequestReplyMessageIntermediary intermediary. It happens when teh intermediary attempts to forward to the service and it doesn't matter whether the service is running or not which tends to suggest its something happening in te intermediary itself. The stack trace is as follows:

"\nServer stack trace: \n
at System.Net.HttpWebRequest.set_Connection(String value)\r\n
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.PrepareHttpSend(Message message)\r\n
at System.ServiceModel.Channels.HttpOutput.Send()\r\n
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)\r\n
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)\r\n
at System.ServiceModel.RequestChannelBinder.Request(Message message, TimeSpan timeout)\r\n
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)\r\n
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\n\nException rethrown at [0]: \n
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n
at System.ServiceModel.IRequestReplyMessageIntermediary.ProcessMessage(Message message)\r\n
at Intermediary.UnreliableIntermediary.ProcessMessage(Message message) in C:\\Work\\RM\\Intermediary\\UnreliableIntermediary.cs:line 33"

Anyone know what this is about?

Regards

Richard Blewett

[2087 byte] By [RichardBlewett] at [2008-2-4]
# 1
Richard,

You're seeing this exception because Indigo is trying to forward the same HTTP headers that the incoming message arrived with on the router-to-service connection. Some of those headers are supported for reading only - like Keep-Alive and Close.

This used to not be a problem in Beta 1 because we didn't integrate with the HTTP subsystem this way - that's why the Intermediary Router sample didn't have to deal with this. I'm assuming you're using the September CTP which does have this integration built in. Unfortunately, the samples never got updated.

The recommended practice is to strip the incoming message that is about to be forwarded of all its HTTP headers. You can do this with:

// Remove all framing-level HTTP information that the message was tagged with when it was received.
message.Properties[HttpRequestMessageProperty.Name] = null;

You'll also want to remove any headers that the response may have arrived with before returning it from ProcessMessage. You can do that with:

// Remove all framing-level HTTP information that the response was tagged with when it was received.
response.Properties[HttpResponseMessageProperty.Name] = null;

The Beta 2 version of the sample uses this.

Ondrej

OndrejHrebicek at 2007-9-9 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified