Closed 18wu closed 2 years ago
@18wu Could you describe the issue a bit more clearly? What is the current behavior? What is the expected behavior? What version of the Plugin are you using? Do you have any Kong logs?
the timeout config : but when I delete the plugin or disabled the plugin, the meaasge still shows "timeout". I see the code is: maybe that's the problem. the plugin version is the lastest!
Could you also check the timeout value for the Service Object? It is possible that the Upstream Server is taking too long to respond and in that time Kong is timing out the request (which is just an HTTP Client thing, nothing to do with circuit breaker or Kong).
the timeout value for the Service Object : default 60000ms. The problem is that this plugin modified the timeout configuration, but it did not change the configuration back after closing the plugin.
I am not sure if that is the case since ngx.ctx is a per request table, So it needs to be set for each request. Nevertheless I will try to replicate it on my end. Could you help me out with the plugin version you are using?
v2.1.0
@18wu When you first set (or make any subsequent changes) to the timeout value, the timeout gets reflected in the 2nd request. The first request you hit after making the changes uses the old timeout value which is cached at Kong level. Let's say-
If you still face issues please post the steps to replicate the issue.
I know what you mean,You mean that the timeout of the plugin is set, and the first time will not take effect.But my problem is that I deleted the circuit breaker plugin and the request I sent still timed out.
@18wu I was able to replicate this and it is indeed a problem. But for now, I can suggest a workaround that involves enabling a circuit breaker plugin globally which has the default timeout of 60000ms set (or any other value you may like). Meanwhile, I am also looking at how to fix this issue. I encourage you to find a fix as well and contribute if possible.
ok,thanks
@18wu I looked over Kong's source code to understand why request level data (kong.ctx) is somehow propagating to subsequent requests. Turns out that ngx.ctx has a reference to the service and route objects, and if we modify any property for these objects, that change persists for subsequent requests(In our case ngx.ctx.service.read_timeout)
The actual value used for setting timeouts is ngx.ctx.balancer_data Refer source code. Our code was working since balancer_data is created per request using the service level config, Refer source code.
So if we just change ngx.ctx.service.read_timeout to ngx.ctx.balancer_data.read_timeout, the issue will be solved. Would you be willing to contribute to this change? Along with test cases if possible?
I changed ngx.ctx.service.read_timeout to ngx.ctx.balancer_data.read_timeout,now the call is like this.
I can't see anything in the video, it's just a black screen. Could you repost it or maybe describe the issue?
download it. I can't describe it accurately, which means that I asked for it 10 times, five times will be Timeout, five times will be normal, and it will always be Timeout until it is modified.
What is the api_call_timeout_ms value?
2ms
And I found that now the plugin is enabled, which is also the above situation.
So 2ms is a very small value, and if for any reason the app or Kong takes longer than that, you'll get a timeout. However, if you set the value to 2ms, and then remove the plugin, the timeout value should fall back to the timeout configured on the service. Which I think solves your issue, right?
Now the problem is changed to ngx.ctx.balancer_data.read_timeout, but it seems useless. Can you try it yourself?
I tried it out on local and it works for me. If I set the timeout to say 100ms, and the API takes more than that, Kong returns a timeout error. And if I remove the plugin, and service timeout is set to say 60000ms (default), then the request does not time out, and Kong returns a proper response. If you remove the circuit breaker plugin and set the value to 2ms at the service level, you will face the same issue(some requests will pass and some will not) which is fine since the upstream or Kong might take more time than that. But this change fixes your earlier issue, which was the timeout issue even after deleting the plugin.
ok,Thank you very much.
Any updates on when the above mentioned fix will be introduced in a new release of the plugin?
Will push the fix in a couple of days.
Summary
If a timeout is triggered,when I disabled this plugin,it also say "The upstream server is timing out". Very urgent
Steps To Reproduce
1. 2. 3. 4.
Additional Details & Logs
$ kong 2.4.1
)$ kong start --vv
)<KONG_PREFIX>/logs/error.log
)