当前位置:网站首页>webflux - webclient Connect reset by peer Error
webflux - webclient Connect reset by peer Error
2022-07-07 23:45:00 【iiaythi】
webflux - webclient Connect reset by peer Error
Connect reset by peer problem
Connection reset by peer The server is on the opposite side Socket It is caused by transferring data to the connection after it is closed , But the reason why the opposite end closes the connection is unknown
It can happen on the client side and the server side
Some common socket problem
| abnormal | reason |
|---|---|
| java.net.BindException:Address already in use: JVM_Bind | This exception occurs on the server side new ServerSocket(port) In operation , The reason is that the local port has been occupied by other programs . Use at this time netstat –an command , You can see the ports that are already in use locally , Using an unoccupied port can solve this problem |
| java.net.ConnectException: Connection refused: connect | This exception occurs on the client side new Socket(ip, port) In operation , The reason is that the target cannot be found ip Server of address ( That is, from the current machine does not exist to the specified ip The routing ), Or it's time to ip There is , But there is no program listening on the specified port on the target server |
| java.net.SocketException: Socket is closed | This exception may occur on both the client and the server , The reason is that after your side actively closes the connection ( Called Socket#close() Method ) Then read and write the network connection |
| java.net.SocketException: Connect reset by peer | The other is ,TCP Both ends have exchanged FIN The message closes the connection normally , But one end still uses the connection to read and write data |
| java.net.SocketException: Connection reset | Current end Socket Received the opposite RST The data is still read after the message |
| java.net.SocketException: Broken pipe | This exception can occur on both the client and the server , The front end is disconnected before reading and writing data ( For example, when the front-end program is ready to write data to Socket, Result initiation IO The program exits abnormally after calling ), Then throw the exception |
Online reasons
- reactor-netty The connection pool allocates threads reactor-http-epoll-1 Processing a request A,reactor-http-epoll-1 The processing process is slow SQL It has been blocked 60s, During this period, the same interface is accessed with high frequency , Other threads in the connection pool are also assigned to handle the same kind of requests , And then because it's slow SQL Block up . When the threads in the connection pool are blocked , New requests come , There are no threads in the connection pool to process it , Therefore, the requester has been hold, Until it shuts down after timeout Socket. After that, the server connection pool thread finally finished processing slowly SQL request , Then deal with the backlog of requests , After completion, send the data to the requester , But found that the connection has been closed , And then they reported Connection reset by peer error . The experience gained from this investigation is , If the service reports Connection reset by peer error , First, check whether there is a particularly slow action in the service that blocks the thread
- Article address : connect reset by peer
Solution
Set as a short connection
public WebClient client() { if (webClient == null) { synchronized (lock) { if (webClient == null) { ClientHttpConnector connector = new ReactorClientHttpConnector(HttpClient.create().keepAlive(false)); webClient = WebClient.builder().clientConnector(connector).baseUrl("svc-user").build(); } } } return webClient; }
Set timeout
ConnectionProvider provider = ConnectionProvider.builder("fixed") .maxConnections(500) .maxIdleTime(Duration.ofSeconds(20)) .maxLifeTime(Duration.ofSeconds(60)) .pendingAcquireTimeout(Duration.ofSeconds(60)) .evictInBackground(Duration.ofSeconds(120)).build(); this.webClient = WebClient.builder() .clientConnector(new ReactorClientHttpConnector(HttpClient.create(provider))) .build();
Connect reset problem
Connection reset The server is on the opposite side Socket` It is caused by reading data to the connection after it is closed , But the reason why the opposite end closes the connection is unknown
It can happen on the client side and the server side
边栏推荐
- ping报错:未知的名称或服务
- [experiment sharing] log in to Cisco devices through the console port
- P1308 [noip2011 popularity group] count the number of words
- How did a fake offer steal $540million from "axie infinity"?
- 35岁那年,我做了一个面临失业的决定
- ASP. Net query implementation
- AWS AWS help error
- Dependency injection 2 advantage lifecycle
- Go time package common functions
- 2022.7.7-----leetcode.648
猜你喜欢

【LeetCode】20、有效的括号

Class C design questions

Get started with mongodb

Anxinco EC series modules are connected to the multi protocol access products of onenet Internet of things open platform

Learn about scratch
![[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware](/img/bc/8241a339cca9b7af475169dba39c10.jpg)
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware

Take you hand in hand to build feign with idea

0-1 knapsack problem

【路径规划】使用垂距限值法与贝塞尔优化A星路径

Apng2gif solutions to various problems
随机推荐
Restricted linear table
Chisel tutorial - 02 Chisel environment configuration and implementation and testing of the first chisel module
Flash encryption process and implementation of esp32
【路径规划】使用垂距限值法与贝塞尔优化A星路径
About the difference between ch32 library function and STM32 library function
Possible SQL for Oracle table lookup information
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
Boost regex library source code compilation
507 field D - extraterrestrial relics
激光slam学习(2D/3D、偏实践)
Ora-02437 failed to verify the primary key violation
Uic564-2 Appendix 4 - flame retardant fire test: flame diffusion
Markdown
Arbre binaire équilibré [Arbre AVL] - Insérer et supprimer
HB 5469民用飞机机舱内部非金属材料燃烧试验方法
Jisuan Ke - t3104
神奇快速幂
[summary] some panels and videos seen
An example analysis of MP4 file format parsing
B_ QuRT_ User_ Guide(39)