apache / shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
https://shenyu.apache.org/
Apache License 2.0
8.43k stars 2.93k forks source link

[Question] <Shenyu gateway SpringCloud proxy timeout problem> #2976

Closed huaweiecho closed 1 year ago

huaweiecho commented 2 years ago

Question

shenyu version 2.4.2 In the case of debugging interface timeout problems. When I set the HTTP timeout to the following configuration, Service provider interface Sleep 5000ms, The gateway generates a timeout error after 3000ms each time. http config shenyu.httpclient.strategy=webClient shenyu.httpclient.connectTimeout=45000 shenyu.httpclient.readTimeout=10000 shenyu.httpclient.writeTimeout=10000

gateway error response: { "code": 500, "message": "Internal Server Error", "data": { "cause": null, "stackTrace": [ { "methodName": "handleTimeout", "fileName": "FluxTimeout.java", "lineNumber": 288, "className": "reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber", "nativeMethod": false } ], "localizedMessage": "Did not observe any item or terminal signal within 3000ms in 'peekTerminal' (and no fallback has been configured)", "message": "Did not observe any item or terminal signal within 3000ms in 'peekTerminal' (and no fallback has been configured)", "suppressed": [ { "cause": null, "stackTrace": [ { "methodName": "handleTimeout", "fileName": "FluxTimeout.java", "lineNumber": 288, "className": "reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber", "nativeMethod": false }, { "methodName": "doTimeout", "fileName": "FluxTimeout.java", "lineNumber": 273, "className": "reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber", "nativeMethod": false }, { "methodName": "onNext", "fileName": "FluxTimeout.java", "lineNumber": 395, "className": "reactor.core.publisher.FluxTimeout$TimeoutTimeoutSubscriber", "nativeMethod": false }, { "methodName": "onNext", "fileName": "StrictSubscriber.java", "lineNumber": 89, "className": "reactor.core.publisher.StrictSubscriber", "nativeMethod": false }, { "methodName": "onNext", "fileName": "FluxOnErrorResume.java", "lineNumber": 73, "className": "reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber", "nativeMethod": false }, { "methodName": "run", "fileName": "MonoDelay.java", "lineNumber": 117, "className": "reactor.core.publisher.MonoDelay$MonoDelayRunnable", "nativeMethod": false }, { "methodName": "call", "fileName": "SchedulerTask.java", "lineNumber": 68, "className": "reactor.core.scheduler.SchedulerTask", "nativeMethod": false }, { "methodName": "call", "fileName": "SchedulerTask.java", "lineNumber": 28, "className": "reactor.core.scheduler.SchedulerTask", "nativeMethod": false }, { "methodName": "run$$$capture", "fileName": "FutureTask.java", "lineNumber": 266, "className": "java.util.concurrent.FutureTask", "nativeMethod": false }, { "methodName": "run", "fileName": "FutureTask.java", "lineNumber": -1, "className": "java.util.concurrent.FutureTask", "nativeMethod": false }, { "methodName": "access$201", "fileName": "ScheduledThreadPoolExecutor.java", "lineNumber": 180, "className": "java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask", "nativeMethod": false }, { "methodName": "run", "fileName": "ScheduledThreadPoolExecutor.java", "lineNumber": 293, "className": "java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask", "nativeMethod": false }, { "methodName": "runWorker", "fileName": "ThreadPoolExecutor.java", "lineNumber": 1149, "className": "java.util.concurrent.ThreadPoolExecutor", "nativeMethod": false }, { "methodName": "run", "fileName": "ThreadPoolExecutor.java", "lineNumber": 624, "className": "java.util.concurrent.ThreadPoolExecutor$Worker", "nativeMethod": false }, { "methodName": "run", "fileName": "Thread.java", "lineNumber": 748, "className": "java.lang.Thread", "nativeMethod": false } ], "message": "\nError has been observed at the following site(s):\n\t|_ checkpoint ⇢ org.apache.shenyu.web.configuration.ErrorHandlerConfiguration$1 [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.ExcludeFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.FileSizeFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.CrossFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.LocalDispatcherFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ com.shengpay.shenyu.core.filter.MdcWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ com.shengpay.shenyu.core.filter.RequestCatWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ HTTP POST \"/testccc/api/c/test1\" [ExceptionHandlingWebHandler]\nStack trace:", "localizedMessage": "\nError has been observed at the following site(s):\n\t|_ checkpoint ⇢ org.apache.shenyu.web.configuration.ErrorHandlerConfiguration$1 [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.ExcludeFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.FileSizeFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.CrossFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.apache.shenyu.web.filter.LocalDispatcherFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ com.shengpay.shenyu.core.filter.MdcWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ com.shengpay.shenyu.core.filter.RequestCatWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]\n\t|_ checkpoint ⇢ HTTP POST \"/testccc/api/c/test1\" [ExceptionHandlingWebHandler]\nStack trace:", "suppressed": [] } ] } }

AhahaGe commented 2 years ago

is this a repeat issue, does this one the same with yours #2882 ?

p8rtop commented 2 years ago

shenyu 2.4.2 1.login your shenyu-admin web 2.PluginList-->Proxy-->SpringCloud-->RulesList-->Modify-->Handler-->timeout default 3000ms 3.Set timeout parameters

For other versions, perform similar operations. Configure your rules.

huaweiecho commented 2 years ago

case1: shenyu.httpclient.readTimeout=3000 shenyu.httpclient.writeTimeout=3000

rule timeout:10s

provider server sleep:8s

error:io.netty.handler.timeout.ReadTimeoutException: null

case2: shenyu.httpclient.readTimeout=10000 shenyu.httpclient.writeTimeout=10000

rule timeout:10s

provider server sleep:8s

invoke success

case3:

shenyu.httpclient.readTimeout=10000 shenyu.httpclient.writeTimeout=10000

rule timeout:3s

provider server sleep:8s

error:Resolved [TimeoutException: Did not observe any item or terminal signal within 3000ms in 'peekTerminal'