Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call API with large header #3704

Closed
tieudaotu90 opened this issue Sep 23, 2021 · 17 comments
Closed

Cannot call API with large header #3704

tieudaotu90 opened this issue Sep 23, 2021 · 17 comments
Labels
kind/bug Something isn't working

Comments

@tieudaotu90
Copy link

In what area(s)?

/area runtime

What version of Dapr?

Version 1.2.2

Expected Behavior

2 Microservices communicate with each other with using DapR sidecar successful as same as directly communication

Actual Behavior

If any header field is over 3818 Byte , we got error 431 Request Header Fields Too Large.

Steps to Reproduce the Problem

Any thoughts?

Thanks

@tieudaotu90 tieudaotu90 added the kind/bug Something isn't working label Sep 23, 2021
@yaron2
Copy link
Member

yaron2 commented Sep 23, 2021

@daixiang0 can you please check what setting we need to expose or change to fix this?

@yaron2 yaron2 added this to the v1.5 milestone Sep 23, 2021
@daixiang0
Copy link
Member

@tieudaotu90 did you test with many kinds of data sizes and confirm 3818 is a limit? Could you share the request which result in this error?

It often produces when:

  • request URL is too long
  • too many cookies sent in the request

Also you said that the error occur in the microservice logs, does microservice limit this size?

@tieudaotu90
Copy link
Author

tieudaotu90 commented Sep 23, 2021

@daixiang0 Here is my scenario:

  • Postman client call to MS2 , and then MS2 forward this request to MS1 (include the header from Postmant client).
  • I was put a Http header called Authorization (just for testing , I dont use any data in this field).
  • Both Microservices (spring boot) has config server.max-http-header-size=48000 (I was test without DapR, larger header is not problem )

In Postman, if I call with 3818 character Authorization header. it show 200 OK.
If I put a character more into this field. it show

{
"timestamp": "2021-09-23T04:32:31.744+0000",
"status": 500,
"error": "Internal Server Error",
"message": "status 431 reading SOAMappingRestFeign#callRestEureka(String,String,String)",
"path": "/soahttperrormapping/v1.0"
}

Here is log in MS2

2021-09-23 09:58:59.469 INFO--[18-nio-8709-exec-4] [16245f09-8f22-41f8-bf7f-d783fb8100d8]c.e.q.t.SoaErrorCodeMappingController :callfailed feign.FeignException: status 431 reading SOAMappingRestFeign#callRestEureka(String,String,String)
2021-09-23 09:58:59.471 ERROR--[18-nio-8709-exec-4] [16245f09-8f22-41f8-bf7f-d783fb8100d8]o.a.c.c.C.[.[.[.[dispatcherServlet] :Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.FeignException: status 431 reading SOAMappingRestFeign#callRestEureka(String,String,String)] with root cause
feign.FeignException: status 431 reading SOAMappingRestFeign#callRestEureka(String,String,String)
at feign.FeignException.errorStatus(FeignException.java:78)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:93)

Here is simple caller from MS2 to MS1:

@FeignClient( url = "${ms1.url}")
public interface SOAMappingRestFeign {
@RequestMapping(method = RequestMethod.GET, value = "/soahttperrormapping/v1.0", consumes = "application/json")
@headers({"Content-Type: application/json")
String callRestEureka(@RequestHeader("Authorization") String Authorization,@RequestHeader("ClientMessageId") String ClientMessageId, @RequestParam String soaErrorCode);
}

Request from Postman (curl format)

curl -X GET
'http://10.1.27.41:8709/soahttperrormapping/v1.0?soaErrorCode=123'
-H 'Authorization: 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'
-H 'ClientMessageId: 72f8eaf7-a068-4ba0-af3c-ce1dca3d6615'

@daixiang0
Copy link
Member

"message": "status 431 reading SOAMappingRestFeign#callRestEureka(String,String,String)",

Do you test without Dapr? 500 means error is from MS.

@tieudaotu90
Copy link
Author

yes, without DapR with the same postman testcase. this show OK.
500 mean http status = 500 from MS2 return to Postman. we don't need to pay attention to this place.
431 means error is from MS1 return back to MS2 and only occur if communication with DapR sidecar.

@daixiang0
Copy link
Member

daixiang0 commented Sep 23, 2021

I test with https://github.com/dapr/quickstarts/tree/master/hello-kubernetes:

root:[hello-kubernetes]$ curl -H 'Authorization: 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' http://localhost:8080/order
{"orderId":"42"}

It works with one MS.

@tieudaotu90
Copy link
Author

I was read this page, but it's seem the Authorization is not used to forward from Python-Pod to Node-Pod.
Your test case is normal case that call from client to a Pod and then return result (this is Rest API - HTTP, Authorization will not forward to other Pod).
Could you try to forward the Authorization header between 2 pods ?

@daixiang0
Copy link
Member

daixiang0 commented Sep 23, 2021

Need time to create this case, could you share dapr logs with debug level for this?

@tieudaotu90
Copy link
Author

Where log you need to view, is sidecar log ? And if you don't mind, can you tell me how to enable dapr debug log

@Taction
Copy link
Member

Taction commented Sep 23, 2021

@daixiang0 This may be a problem related to fasthttp. It has a ReadBufferSize parameter, which limits the maximum header size. And its default value is 4096.

@saber-wang
Copy link

I also have this problem #3408

@daixiang0
Copy link
Member

daixiang0 commented Sep 26, 2021

@tieudaotu90 you can add dapr.io/log-level: "debug" to annotations to enable.

@Taction --dapr-http-max-request-size is unlimited as default, see https://docs.dapr.io/operations/configuration/increase-request-size/. @tieudaotu90 please confirm this config in sidecar using "kubectl describe pod xxx".

@Taction
Copy link
Member

Taction commented Sep 26, 2021

@daixiang0 The --dapr-http-max-request-size flag controls [MaxRequestBodySize](https://github.com/valyala/fasthttp/blob/master/server.go#L261), the param I mentioned is [ReadBufferSize](https://github.com/valyala/fasthttp/blob/master/server.go#L206). Besides, there is an existing pr #3346 working on this.

@daixiang0
Copy link
Member

Oh, sorry for that.

@tieudaotu90
Copy link
Author

Hi @daixiang0 @Taction , As I understand, this bug is in processing? Can you let me know about the plan when it's completed?

@Taction
Copy link
Member

Taction commented Sep 27, 2021

@tieudaotu90 Yes, you can pay attention to the pr I mentioned above.

@artursouza
Copy link
Member

Duplicate of #3408

@artursouza artursouza marked this as a duplicate of #3408 Sep 29, 2021
@artursouza artursouza removed this from the v1.5 milestone Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants