Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
38.98k stars 4.78k forks source link

Proxy Buffering Settings Cause Issues #13211

Closed Hicham-Chahboune closed 2 months ago

Hicham-Chahboune commented 3 months ago

Is there an existing issue for this?

Kong version ($ kong version)

3.7.0

Current Behavior

When sending a very large request, Nginx (of kong) buffers it in a file. However, in a plugin, if I attempt to read the body from the request, it doesn't retrieve the body from that file and returns an error. The solution I found is to increase the Nginx buffer size, which works, but this is not ideal, especially when receiving multiple large requests, as is my case.

Current Configuration: proxy_buffering on; proxy_buffer_size 32k; proxy_buffers 64 16k; proxy_busy_buffers_size 256k; proxy_max_temp_file_size 200m; proxy_temp_file_write_size 1024k;

ERROR MESSAGE:

a client request body is buffered to a temporary file /usr/local/kong/client_body_temp/0000000001 /usr/local/share/lua/5.1/MessagePack.lua:126: attempt to get length of local 'str' (a nil value)

Expected Behavior

Expected Behavior:

The body should be retrievable from the file without needing to increase the buffer size of nginx.

Steps To Reproduce

Steps to Reproduce:

Anything else?

a client request body is buffered to a temporary file /usr/local/kong/client_body_temp/0000000001, /usr/local/share/lua/5.1/MessagePack.lua:126: attempt to get length of local 'str'

StarlightIbuki commented 3 months ago

This is by design and not a bug for PDK. It looks like you are using JS or Python PDK; currently, we do not support reading from cached files. We have a WIP PR to support it: a76d657 (#13158)

github-actions[bot] commented 2 months ago

This issue is marked as stale because it has been open for 14 days with no activity.

github-actions[bot] commented 2 months ago

Dear contributor,

We are automatically closing this issue because it has not seen any activity for three weeks. We're sorry that your issue could not be resolved. If any new information comes up that could help resolving it, please feel free to reopen it.

Your contribution is greatly appreciated!

Please have a look our pledge to the community for more information.

Sincerely, Your Kong Gateway team