Submit request to HttpServer in MessageHandler cause failure during pipeline creation


Check out the attach sample. It is built based on Brad's batching sample: http://bradwilson.typepad.com/blog/2012/06/batching-handler-for-web-api.html

One customized message handler is added to the global configuration. Run the client, you will notice all the inner request are return 400 Bad Request.

The exception happens in HttpClientFactory.CreatePipeline. When a request is submitted to HttpServer, the server tries to ensure the pipeline is created, which invoke a re-create a established pipeline.

file attachments

Closed Sep 11, 2013 at 9:37 PM by yishaigalatzer
Since we implemented batching in the framework. We don't feel it's important to fix anymore.

If there is another scenario requiring fixing this, feel free to re-open and specify the scenario.


HongmeiG wrote Jun 22, 2012 at 4:57 PM

We will fail because we tried to wire up the message handler twice.

HongmeiG wrote Jun 26, 2012 at 12:55 AM

We should consider making this experience better. Possible solution could be:
  1. Making a configuration a clonable object;
  2. Instead of throw exception, allowing the config to be re-used;

roncain wrote Jul 19, 2012 at 12:49 PM

The actual error is attempting to wire up the pipeline twice. I've tested a local fix in CreatePipeline to simply detect the inner handlers are already set and return. Here is the code for CreatePipeline (added immediately after checking input parameters):
         DelegatingHandler firstHandler = handlers.FirstOrDefault();
        if (firstHandler != null && firstHandler.InnerHandler != null)
            return firstHandler;
Alternatively, the config would need to carry state that its handlers had been initialized.

HongmeiG wrote Mar 29, 2013 at 1:18 AM

Yes, we should remove this throw.

eilonlipton wrote Jun 17, 2013 at 12:00 AM

Moving to vNext. In the meantime we recommend using the mitigation described in this blog post: http://trocolate.wordpress.com/2012/07/19/mitigate-issue-260-in-batching-scenario/

blake05 wrote May 22, 2014 at 8:17 PM

Please reopen this issue to ensure it's fixed in vnext