Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sl-gateway
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouwei
sl-gateway
Commits
af9e4fac
Commit
af9e4fac
authored
Apr 21, 2025
by
zhouwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增强超时处理逻辑
parent
1c983936
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
AppConfig.java
src/main/java/com/nanyan/securitylink/config/AppConfig.java
+3
-3
FailoverGatewayFilterFactory.java
...yan/securitylink/filter/FailoverGatewayFilterFactory.java
+8
-2
No files found.
src/main/java/com/nanyan/securitylink/config/AppConfig.java
View file @
af9e4fac
...
...
@@ -12,10 +12,10 @@ import org.springframework.context.annotation.Configuration;
public
class
AppConfig
{
@Value
(
"${alert.host}"
)
String
alertHost
;
@Value
(
"${gateway.request.timeout:
5
0000}"
)
private
int
requestTimeout
;
@Value
(
"${gateway.request.timeout:
3
0000}"
)
private
Integer
requestTimeout
;
public
int
getRequestTimeout
()
{
public
Integer
getRequestTimeout
()
{
return
requestTimeout
;
}
...
...
src/main/java/com/nanyan/securitylink/filter/FailoverGatewayFilterFactory.java
View file @
af9e4fac
...
...
@@ -265,11 +265,17 @@ public class FailoverGatewayFilterFactory extends AbstractGatewayFilterFactory<F
log
.
info
(
"request id:{} Starting {} request to: {}"
,
exchange
.
getAttributes
().
get
(
REQUEST_ID
),
isSourceRequest
?
"source"
:
"target"
,
fullUrl
);
long
startTime
=
System
.
currentTimeMillis
();
Integer
requestTimeout
=
appConfig
.
getRequestTimeout
();
// 创建 WebClient 请求
if
(!
isSourceRequest
){
//第二次请求兜底增长时间
requestTimeout
=
requestTimeout
+
50000
;
}
WebClient
client
=
webClientBuilder
.
clone
()
.
clientConnector
(
new
ReactorClientHttpConnector
(
HttpClient
.
create
()
.
option
(
ChannelOption
.
CONNECT_TIMEOUT_MILLIS
,
appConfig
.
getRequestTimeout
()
)
.
responseTimeout
(
Duration
.
ofMillis
(
appConfig
.
getRequestTimeout
()
))))
.
option
(
ChannelOption
.
CONNECT_TIMEOUT_MILLIS
,
requestTimeout
)
.
responseTimeout
(
Duration
.
ofMillis
(
requestTimeout
))))
.
build
();
WebClient
.
RequestBodySpec
requestBodySpec
=
client
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment