Spring-cloud-netflix: GET request 411 error on zuul proxy for eureka clients.

Created on 31 Mar 2017  路  15Comments  路  Source: spring-cloud/spring-cloud-netflix

After updating to _Camden_ release, previously reported issue #1042 (411 content length required) is appearing again for GET requests.

I've following config on my small demo app. :

zuul:
  ignoredServices: '*'
  routes:
    rs: /api/rs/**
    httpbin: 
      path: /api/httpbin/**
      url: http://httpbin.org

I've 2 routes: eureka client rs and direct proxy for httpbin.
Eureka client was throwing 411 error on GET requests. The difference was eureka client is setting unnecessary additional Transfer-Encoding: chunked header.

If we can't remove this header, I think we can set Content-Length: 0, as it was handled previously.

My config app is running with simple default config (no custom RibbonCommandFactory):

@SpringBootApplication
@EnableZuulProxy
@EnableDiscoveryClient
public class Zuul411Application {

    public static void main(String[] args) {
        SpringApplication.run(Zuul411Application.class, args);
    }

}

p.s This issue is only apparent for certain network and ISPs.

bug

All 15 comments

This issue is only apparent for certain network and ISPs.

Why does the issue only show up on certain networks?

We just fixed this in bd3391ae55a3c63dbd19a1b7ef4f2bfd5765ea34. Please try with Camden.SR6. I believe this is a duplicate of #1705

@ryanjbaxter I guess some ISPs dont allow transfer-encoding: chunked for GET requests. It works fine from other networks, but our office network doesn't allow it when we try to make GET requests to cloud foundry from local instance.

It also used to happen before this commit, when content-length was not set for non-get requests.

Have you tried the fix mentioned above?

@spencergibb I'm already running on Camden.SR6. Though I don't know much of the internals, it looks like your commit relates to feign clients, no?

My issue is with zuul proxy, proxying eureka client. Here's the log when I try GET to /api/rs, which results in 411 error:

2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> GET /get HTTP/1.1
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> pragma: no-cache
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> cache-control: no-cache
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> accept: */*
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> x-requested-with: XMLHttpRequest
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> content-type: application/json
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> referer: http://localhost:8080/
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> accept-language: en-US,en;q=0.8,bg;q=0.6,ru;q=0.4
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> x-forwarded-host: localhost:8080
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> x-forwarded-proto: http
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> x-forwarded-prefix: /api/rs
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> x-forwarded-port: 8080
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> x-forwarded-for: 0:0:0:0:0:0:0:1
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> Accept-Encoding: gzip
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> Transfer-Encoding: chunked
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> Host: demo-rs.cfapps.io:80
2017-04-03 10:01:03.683 DEBUG 6843 --- [nio-8080-exec-7] org.apache.http.headers                  : http-outgoing-1 >> Connection: Keep-Alive

But when I make GET to /api/httpbin, which is a "direct" url proxy, it works fine:

2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> GET /get HTTP/1.1
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> pragma: no-cache
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> cache-control: no-cache
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> accept: */*
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> x-requested-with: XMLHttpRequest
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> content-type: application/json
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> referer: http://localhost:8080/
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> accept-language: en-US,en;q=0.8,bg;q=0.6,ru;q=0.4
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> x-forwarded-host: localhost:8080
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> x-forwarded-proto: http
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> x-forwarded-prefix: /api/httpbin
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> x-forwarded-port: 8080
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> x-forwarded-for: 0:0:0:0:0:0:0:1
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> Accept-Encoding: gzip
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> Host: httpbin.org
2017-04-03 10:04:33.103 DEBUG 6843 --- [nio-8080-exec-9] org.apache.http.headers                  : http-outgoing-2 >> Connection: Keep-Alive

So from here, the only difference is that Transfer-Encoding: chunked was set for eureka client request. If we could remove this unnecessary header, it would be so much helpful.

I also tested with feign client, and it works fine.

Yup, my bad

Content-Length is being set as -1, that is why the condition is not longer being evaluated.

Tomcat sets the content-length to -1 if there is no content-length header.

Closed via ec4c02aba93c381eeff4d88c9b65cfe73571b71a

Cherry-picked to master 62408af5eae2c02e3391146bf67082a85e3d8a62

Sorry to bother, but may I ask when 1.2.7.RELEASE is likely to be released? Can I jump to 1.3.0.RELEASE? is 1.3.0 compatible with Camden.SR6?

@beku8 There is no timeline for Camden.SR7 and 1.3.0 is not compatible with Camden.SR6.

I've recently updated to Dalston.Release, and everything is working great except we are facing 411 issue again on DELETE requests with empty body.

I think we should set Content-Length: 0, when there's empty body on a DELETE request. This is how it's currently working for POST & PUT requests.

Could you fix this please, @spencergibb ?

FYI, this error(411 on DELETE) is happening on non-eureka client proxies(direct url proxy) as well.
But when its being handled thru feign, it's working properly

@beku8 please open a separate issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mekhaba picture mekhaba  路  4Comments

marcingrzejszczak picture marcingrzejszczak  路  4Comments

todd-wang-in-BJ picture todd-wang-in-BJ  路  3Comments

niral22 picture niral22  路  4Comments

huhuhong picture huhuhong  路  4Comments