GET on Web Api through Service Gateway not send all the data

Feb 6, 2014 at 11:18 PM

I'm using the service Gateway to propose a easy way to access différents Web Api hosted on different endpoint using the same domain.

I'm facing an issue for one GET method.

The Gateway seems to not send all the respond data to the client, indeed, the Web api send 495 038 bytes (length present in the header) but the Service Gateway only transmit 266 551 bytes to the client, this behavior create a disconnection with the client and the data is not return. If the connection is not closed, the content send by the Gateway is truncated : Fiddler Protocol Violation : 105 Content-Length mismatch: Response Header indicated 493 892 bytes, but server sent 231 474 bytes.

My controller method is simple and consist of calling a database using EF 6. It's works perfectly if I call my web service directly.

Do I have to customize something on the Gateway?

public async Task<IHttpActionResult> GetData(ODataQueryOptions<DataDb> options)
                using (var ctx = InitDbContext(connectionString))
                    (ctx as DbContext).Database.Initialize(true);

                    var results = options.ApplyTo(ctx.Datas.AsQueryable());

                    var queryResult = await results.Cast<DataDb>().ToListAsync();
                    var r = queryResult.Select(item=>  
                        new Data()

                    return Ok(new PageResult<Data>(
            catch (Exception e)
                return BadRequest(e.Message);

Feb 7, 2014 at 2:31 AM
Hi jdevillard:

The problem you've observed is because of a bug in GatewayTracingModule, which is a HTTP module that we put on Gateway instances to have high-precision tracing. The module also maintains a correlation id that can help you to link calls across different layers of your application. Unfortunately the module sets this header in the EndRequest event by mistake. When a large response is processed, the response buffer may have been flushed before this event is triggered, causing the module to fail and subsequent chucks to be sent correctly.

This problem has been fixed in our dev repo but has not been published. I'll keep you posted when this is done.

A temporary workaround is to connect to your Gateway instance, and disable the tracing module by commenting out this line in your web.config file:

<add name="GatewayTracingModule" type="Microsoft.Gateway.Tracing.GatewayTracingModule, GatewayTracingModule"/>

Once the fix is merged, you need to redeploy your Gateway instances to get this fix in place.

Thank you for your interests in Gateway!

Feb 8, 2014 at 9:46 PM
Thanks Haishi,

the workaround fixed the issues and I've uploaded the v0.5.

Thanks a lot. I'm very interested in the Gateway, and I'm currently trying to configure the solution on my computer to customize the different hooks.