315 Star 3.4K Fork 732

dromara / forest

 / 详情

设置代理后,请求线程无限期卡死

待办的
创建于  
2023-03-01 20:29

当前使用Forest版本以及所使用的后端及版本

Forest: version
Backend: (okhttp或httpclient)/version
都有这个问题

该问题是如何引起的?

设置正向代理后,可能由于代理ip不稳定,请求线程会无限期卡死,某个时候有会恢复,目前打印耗时观察到最长是21分钟

重现步骤(如果有请写完整)

报错信息/完整请求日志(如果没有请求日志请把开关打开)

具体请参考我arthas打印的日志,如果需要更具体信息,可以跟我联系

---ts=2023-03-01 15:19:54;thread_name=rob-delay-pool-230;id=10898;is_daemon=false;priority=5;TCCL=org.springframework.boot.loader.LaunchedURLClassLoader@21b8d17c ---[32139.349926ms] org.apache.http.impl.client.CloseableHttpClient:execute() [throws Exception]
+---[100.00% 32139.338141ms ] org.apache.http.impl.client.CloseableHttpClient:execute() #56:ForestJacksonConverter编码器不灵活 [throws Exception]
| ---[100.00% 32139.324157ms ] org.apache.http.impl.client.CloseableHttpClient:execute() [throws Exception] | +---[0.00% 0.002459ms ] org.apache.http.util.Args:notNull() #82 | +---[0.00% 0.007399ms ] org.apache.http.impl.client.CloseableHttpClient:determineTarget() #83 | +---[100.00% 32139.142724ms ] org.apache.http.impl.client.CloseableHttpClient:doExecute() #83 [throws Exception] | ---throw:java.net.SocketTimeoutException #-2 [Read timed out]
`---throw:java.net.SocketTimeoutException #-2 [Read timed out]

---ts=2023-03-01 15:22:24;thread_name=rob-delay-pool-232;id=10a73;is_daemon=false;priority=5;TCCL=org.springframework.boot.loader.LaunchedURLClassLoader@21b8d17c ---[17959.260116ms] org.apache.http.impl.execchain.RedirectExec:execute()
+---[0.00% 0.002165ms ] org.apache.http.util.Args:notNull() #96:通过@FormBody注解将参数标识为表单格式的请求体
+---[0.00% 0.001109ms ] org.apache.http.util.Args:notNull() #97:遇到一些自定义的Response Content-Type,无法正常读取响应内容
+---[0.00% 9.31E-4ms ] org.apache.http.util.Args:notNull() #98:用httpclient的方式上传文件会不成功,但用okhttp就是成功的
+---[0.00% 0.004049ms ] org.apache.http.client.protocol.HttpClientContext:getRedirectLocations() #100:怎么像okHttp那样设置proxy
+---[0.00% 0.001718ms ] org.apache.http.client.protocol.HttpClientContext:getRequestConfig() #105:泛型怎么用?
+---[0.00% min=8.27E-4ms,max=0.00136ms,total=0.002187ms,count=2] org.apache.http.client.config.RequestConfig:getMaxRedirects() #106:能否新增一个QueryFieldKey的注解?
+---[100.00% 17959.225513ms ] org.apache.http.impl.execchain.ClientExecChain:execute() #110:这个支持缓存(Cache)吗?
| ---[100.00% 17959.218853ms ] org.apache.http.impl.execchain.RetryExec:execute() | +---[0.00% 0.001186ms ] org.apache.http.util.Args:notNull() #83 | +---[0.00% 8.82E-4ms ] org.apache.http.util.Args:notNull() #84 | +---[0.00% 8.75E-4ms ] org.apache.http.util.Args:notNull() #85 | +---[0.00% 0.001473ms ] org.apache.http.client.methods.HttpRequestWrapper:getAllHeaders() #86 | ---[100.00% 17959.205178ms ] org.apache.http.impl.execchain.ClientExecChain:execute() #89:请求响应返回中文内容乱码
| ---[100.00% 17959.198611ms ] org.apache.http.impl.execchain.ProtocolExec:execute() | +---[0.00% 0.001223ms ] org.apache.http.util.Args:notNull() #110 | +---[0.00% 8.61E-4ms ] org.apache.http.util.Args:notNull() #111 | +---[0.00% 9.87E-4ms ] org.apache.http.util.Args:notNull() #112 | +---[0.00% 0.001552ms ] org.apache.http.client.methods.HttpRequestWrapper:getOriginal() #114 | +---[0.00% 0.001056ms ] org.apache.http.client.methods.HttpUriRequest:getURI() #117 | +---[0.00% 0.001416ms ] org.apache.http.client.methods.HttpRequestWrapper:setURI() #130 | +---[0.00% 0.001124ms ] org.apache.http.client.protocol.HttpClientContext:getRequestConfig() #133 | +---[0.00% 0.001188ms ] org.apache.http.client.config.RequestConfig:isNormalizeUri() #133 | +---[0.00% 0.008384ms ] org.apache.http.impl.execchain.ProtocolExec:rewriteRequestURI() #133 | +---[0.00% 0.001493ms ] org.apache.http.client.methods.HttpRequestWrapper:getParams() #135 | +---[0.00% 0.001653ms ] org.apache.http.params.HttpParams:getParameter() #136 | +---[0.00% 0.001489ms ] org.apache.http.HttpHost:<init>() #154 | +---[0.00% 0.001247ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #180 | +---[0.00% 0.001032ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #181 | +---[0.00% 0.001407ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #182 | +---[0.00% 0.013072ms ] org.apache.http.protocol.HttpProcessor:process() #184 | +---[100.00% 17959.119684ms ] org.apache.http.impl.execchain.ClientExecChain:execute() #186 | | ---[100.00% 17959.111389ms ] org.apache.http.impl.execchain.MainClientExec:execute()
| | +---[0.00% 0.001729ms ] org.apache.http.util.Args:notNull() #155:代理
| | +---[0.00% 8.25E-4ms ] org.apache.http.util.Args:notNull() #156:spring项目通过定义Bean自动从Spring上下文中注入对应的ForestConverter
| | +---[0.00% 9.66E-4ms ] org.apache.http.util.Args:notNull() #157
| | +---[0.00% 0.002476ms ] org.apache.http.client.protocol.HttpClientContext:getTargetAuthState() #159:希望@OAuth2注解可以添加一个属性自定义认证响应体中的token位置
| | +---[0.00% 0.00149ms ] org.apache.http.client.protocol.HttpClientContext:getProxyAuthState() #164:调用configuration.getLogHandler().setLogger()方法无效
| | +---[0.00% 0.001885ms ] org.apache.http.impl.execchain.RequestEntityProxy:enhance() #171:特殊符号被转义了,求解救
| | +---[0.00% 0.001296ms ] org.apache.http.client.protocol.HttpClientContext:getUserToken() #174:多线程下载时文件丢失
| | +---[0.00% 0.002561ms ] org.apache.http.conn.HttpClientConnectionManager:requestConnection() #176:新增强制UrlEncoded的字符串模板
| | +---[0.00% 0.001401ms ] org.apache.http.client.methods.HttpExecutionAware:isAborted() #178:指定接口使用httpclient或okhttp3
| | +---[0.00% 0.001695ms ] org.apache.http.client.methods.HttpExecutionAware:setCancellable() #182:1.5 版本的maven仓库地址给一个呗
| | +---[0.00% 0.001469ms ] org.apache.http.client.protocol.HttpClientContext:getRequestConfig() #185:添加@URLEncode注解
| | +---[0.00% 0.00182ms ] org.apache.http.client.config.RequestConfig:getConnectionRequestTimeout() #189:data属性设置json字符串 + @Body参数的情况下报NullPointerException
| | +---[0.00% 0.01758ms ] org.apache.http.conn.ConnectionRequest:get() #190:后期可以支持JWT请求吗
| | +---[0.00% 0.001127ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #202:关于请求是否成功的提议
| | +---[0.00% 0.003244ms ] org.apache.http.client.config.RequestConfig:isStaleConnectionCheckEnabled() #204:openjdk15第十五个版本 不是jdk1.5 创建bean异常。
| | +---[0.00% 0.003087ms ] org.apache.http.impl.execchain.ConnectionHolder:() #215:1.5.1 全局扫包导致类加载顺序的问题引起空指针异常
| | +---[0.00% 0.001374ms ] org.apache.http.client.methods.HttpExecutionAware:setCancellable() #218:服务降级问题
| | +---[0.00% 0.001043ms ] org.apache.http.client.methods.HttpExecutionAware:isAborted() #229:使用GET请求错误
| | +---[0.00% 0.001339ms ] org.apache.http.HttpClientConnection:isOpen() #233:Response不带Content-Type和Content-Encoding头时无法正常解析
| | +---[0.00% 0.002064ms ] org.apache.commons.logging.Log:debug() #234:整理和重构测试用例代码
| | +---[99.43% 17856.276383ms ] org.apache.http.impl.execchain.MainClientExec:establishRoute() #236:响应值正常,json乱码
| | +---[0.00% 0.00199ms ] org.apache.http.client.config.RequestConfig:getSocketTimeout() #245:restTemplate.postForEntity请求可以 换成foreset 请求报错
| | +---[0.00% 0.004424ms ] org.apache.http.HttpClientConnection:setSocketTimeout() #247:Forest快捷接口
| | +---[0.00% 0.001872ms ] org.apache.http.client.methods.HttpExecutionAware:isAborted() #250:为什么浏览器的Content-Type是application/x-www-form-urlencoded,但是代码中请求的话却不行?
| | +---[0.00% 0.001532ms ] org.apache.commons.logging.Log:isDebugEnabled() #254:新增 OnRetry 回调函数
| | +---[0.00% 0.002912ms ] org.apache.http.client.methods.HttpRequestWrapper:containsHeader() #258:当请求 302 请求时,Forest 会自动的访问重定向的url,导致 302 的响应头拿不到。
| | +---[0.00% 9.07E-4ms ] org.apache.commons.logging.Log:isDebugEnabled() #259:可以动态配置Backend后端HTTP框架
| | +---[0.00% 0.001938ms ] org.apache.http.impl.auth.HttpAuthenticator:generateAuthResponse() #262:自动重定向控制
| | +---[0.00% 0.001143ms ] org.apache.http.client.methods.HttpRequestWrapper:containsHeader() #264:jdk8以上支持
| | +---[0.00% 0.001399ms ] org.apache.http.conn.routing.HttpRoute:isTunnelled() #264:jdk8以上支持
| | +---[0.00% 0.002411ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #271:依赖Guava包的问题
| | +---[0.57% 102.651291ms ] org.apache.http.protocol.HttpRequestExecutor:execute() #272:支持每个请求都可自定义序列化转换器
| | +---[0.00% 0.00548ms ] org.apache.http.ConnectionReuseStrategy:keepAlive() #275:中文接口名启动报错
| | +---[0.00% 0.001913ms ] org.apache.http.impl.execchain.ConnectionHolder:markNonReusable() #290:retrywhen中的异常被吃掉, 无法抛出. 且异常后仅触发一次重试
| | +---[0.00% 0.009213ms ] org.apache.http.impl.execchain.MainClientExec:needAuthentication() #293:connect-timeout配置在springboot 1.x 版本下无法解析
| | +---[0.00% 0.002487ms ] org.apache.http.client.UserTokenHandler:getUserToken() #326:自定义 hostnameVerifier 和 SSLSocketFactoryBuilder
| | +---[0.00% 0.001976ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #327:功能新增 SSLSocketFactory&X509TrustManager&HostnameVerifier
| | +---[0.00% 0.001779ms ] org.apache.http.HttpResponse:getEntity() #334:主项目没有依赖lang3会报错的问题
| | +---[0.00% 0.001109ms ] org.apache.http.HttpEntity:isStreaming() #335:Get请求里没有传Body
| | ---[0.00% 0.001564ms ] org.apache.http.impl.execchain.HttpResponseProxy:<init>() #340 | +---[0.00% 0.001399ms ] org.apache.http.client.protocol.HttpClientContext:setAttribute() #190 | ---[0.00% 0.002452ms ] org.apache.http.protocol.HttpProcessor:process() #191:后端使用httpclient绕过HTTPS证书验证失败
`---[0.00% 0.00109ms ] org.apache.http.client.config.RequestConfig:isRedirectsEnabled() #113:序列化问题

---ts=2023-03-01 15:23:38;thread_name=rob-delay-pool-229;id=10897;is_daemon=false;priority=5;TCCL=org.springframework.boot.loader.LaunchedURLClassLoader@21b8d17c ---[38789.081225ms] org.apache.http.impl.execchain.MainClientExec:establishRoute()
+---[0.00% 0.001512ms ] org.apache.http.client.protocol.HttpClientContext:getRequestConfig() #382:全局配置引用
+---[0.00% 0.001452ms ] org.apache.http.client.config.RequestConfig:getConnectTimeout() #383
+---[0.00% 0.001564ms ] org.apache.http.conn.routing.RouteTracker:() #384:AddressSource 里面配置 basePath 不生效
+---[0.00% min=0.001329ms,max=0.003701ms,total=0.010374ms,count=4] org.apache.http.conn.routing.RouteTracker:toRoute() #387:调用接口报 SocketTimeoutException: connect timed out
+---[0.00% min=0.001701ms,max=0.003931ms,total=0.011084ms,count=4] org.apache.http.conn.routing.HttpRouteDirector:nextStep() #388:Multipart body must have at least one part
+---[0.02% 7.300592ms ] org.apache.http.conn.HttpClientConnectionManager:connect() #401:RetryWhen重试条件接口在最后一次重试后会执行两次
+---[0.00% 0.002401ms ] org.apache.http.conn.routing.HttpRoute:getProxyHost() #406:可配置异步请求线程池队列大小
+---[0.00% 0.001191ms ] org.apache.http.conn.routing.HttpRoute:isSecure() #407:重构Cookie
+---[0.00% 0.001406ms ] org.apache.http.conn.routing.HttpRoute:isTunnelled() #407:重构Cookie
+---[0.00% 0.003261ms ] org.apache.http.conn.routing.RouteTracker:connectProxy() #407:重构Cookie
+---[99.90% 38750.475558ms ] org.apache.http.impl.execchain.MainClientExec:createTunnelToTarget() #410:当前版本有已知漏洞
+---[0.00% 0.003584ms ] org.apache.commons.logging.Log:debug() #412:http报错超时,实际发送成功
+---[0.00% 0.002832ms ] org.apache.http.conn.routing.RouteTracker:tunnelTarget() #413:可配置注入OkHttpClient和HttpClient对象
+---[0.08% 31.185521ms ] org.apache.http.conn.HttpClientConnectionManager:upgrade() #428:引入Selenium后貌似有冲突
+---[0.00% 0.001644ms ] org.apache.http.conn.routing.HttpRoute:isSecure() #429:forest,表单类型参数请求失败
+---[0.00% 0.00165ms ] org.apache.http.conn.routing.RouteTracker:layerProtocol() #429:forest,表单类型参数请求失败
`---[0.00% 0.002589ms ] org.apache.http.conn.HttpClientConnectionManager:routeComplete() #436:url中参数带有$时,会强制转义,实际无需转义该如何处理。

[arthas@1]$

接口定义(必要时请提供)

评论 (3)

邹俊 创建了任务

这个问题有得到解决吗? 我貌似也遇到了, 用了正向代理之后,项目运行一段时间CPU满了之后下不来, 导致卡死, 项目没有任何业务处理,只有请求第三方接口

重启之后又恢复一段时间 过一段时间又卡死,同样的操作,重启就好了, 不知道什么原因。请问怎么解决?

输入图片说明

tsConnectionManager.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(20000).build());
给这个设置一个默认的socket超时时间即可解决,他源码没有调整,我自己本地建一个相同包名覆盖了他的类

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
1946452 zkeyzvip 1711621100 8094569 zoujun1998 1604374218
Java
1
https://gitee.com/dromara/forest.git
git@gitee.com:dromara/forest.git
dromara
forest
forest

搜索帮助

53164aa7 5694891 3bd8fe86 5694891