Issues with ProxyFeature

Hey @mythz,

We generally run our cloud apps on AWS but due to the needs of a FIPS 140-2 compatible HSM (Azure KeyVault) we are standing up a standalone api in Azure to satisfy the requirement. I don’t want to disrupt the topology of our current api’s, so i thought the ProxyFeature would be the right tool to implement. However, I am getting a “ERR_INVALID_CHUNKED_ENCODING” response when attempting to use it.

I’ve looked into the issue without resolution
through this eventing before coming here but here is the explanation,

We have servicestack api’s running on AWS Lambda. I implemented the following ProxyFeature setup:

Plugins.Add(new ProxyFeature(
    req => true, //req.PathInfo.StartsWith("/keyvault"),
    req => "https://enumis-api-keyvault.azurewebsites.net")

As a note, this happens identically between localhost and behind api gateway, so we can rule out any issues with API Gateway.

When I make a request to the proxy url, the request goes through, I check the response and I see the html content of the proxied endpoint.

I am not sure where this is failing between the response and displaying in the browser.

Any questions or help is welcomed.

Thanks.

What host are you using this on, i.e. .NET Core, ASP.NET, Self Host HttpListener?

We are using .NET Core

This Issue should now be resolved from this commit. This change is available from v5.1.1 that’s now available on MyGet.

1 Like

@mythz

I’m still seeing this behavior when I try to use the ProxyPlugin in order to passthru access to Elastic Search.

In Chrome I get the ERR_INVALID_CHUNKED_ENCODING message when accessing ES via the ProxyPlugin but not when I access it directly.

Elastic Search is returning the following headers:

HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-encoding: gzip
transfer-encoding: chunked

To test this I did the following:

  1. Create a new “ServiceStack ASP.NET Empty” Solution
  2. Update to ServiceStack 5.1.1
  3. Add the following to AppHost.cs

AppHost.cs:25

this.Plugins.Add(new ProxyFeature(    
    matchingRequests: req => req.PathInfo.StartsWith("/p/search"),    
    resolveUrl: req => "http://elasticserver:9200/collection/_search"));

I’m not really sure if I should expect the ProxyPlugin to deliver content transmitted in a chunked manner or not.

Many thanks!

-Z

Do you have (or know of) a public URL I can test against to repro this issue?

I’ve been investigating this a bit further and found that I get INVALID_CHUNKED when I test against ES 5.5.1, but when I test against 6.2.4 it works correctly.

I’m not sure if this is ES doing something out-of-spec, or if this is just an edge case.

I’ve set up a test server temporarily to help recreate the issue: http://34.201.165.202:9200/shakespeare/_search

I’m testing with:

    public override void Configure(Container container)
    {
        //Config examples
        //this.Plugins.Add(new PostmanFeature());
        //this.Plugins.Add(new CorsFeature());
        this.Plugins.Add(new ProxyFeature(
            matchingRequests: req => req.PathInfo.StartsWith("/p/search"),
            resolveUrl: req => "http://34.201.165.202:9200/shakespeare/_search"));
    }

-Z

This endpoint is working without issue in Chrome:

Ugh. Sorry to make you chase this ghost…

For some reason I’m still seeing it when testing against the test endpoint.

I was wondering if maybe my Nuget files were out of date, but I see 5.1.1.0 on ServiceStack.dll.

Can you think of anything else I should look at in my environment to help explain this?

Many thanks!

-Z

Try clearing out your NuGet cache in-case you’re not referencing the latest v5.1.1 release:

nuget locals all -clear

I’ve made sure to flush my local cache, cleaned the project and deleted the content of the packages directory. When I do a rebuild I see all the packages downloaded from MyGet. The project builds correctly, but I still see the same behavior.

We’ve tested this on two computers at my office with the same effect.

Is this something to do with base configuration from the “ASP.NET Empty” template?

Here is the Solution we’re testing: [SNIP]

Thanks again!

-Z

ok looks like it was a case-insensitive issue resolved with this commit. So should work if with the latest v5.1.1 NuGet packages on MyGet after clearing your existing NuGet package cache.

1 Like

Awesome! Works for me now.

Many thanks!

-Z

1 Like