[JAVA] Stop resending from client to server


In this case, I am not a party, I just heard it, so there may be many ambiguous expressions.

The response from the server took a long time

There was an event that the client (Java) was connecting to the server via LB and the response from the server took n minutes. It takes n minutes because of the large amount of data in the request, which is a specification in a sense (without the tsukkomi that it is not cool). I knew it would take a long time, but after n minutes, the same request arrived at the server. alt

Since the same request was resent, an error occurred on the server side, but I did not know who made the above figure (2). It seems that there were no particular exceptions on the client side.

Who resent

The culprit was the client Java. The LB I was using was supposed to return fin to the client side if there was no response for n minutes. In Java, it was supposed to resend without permission. As stated in RFC2616, Java also says that if you cannot connect by POST, you should send it again. I think it follows that. In addition, this time I used Commons-HttpClient (3.x), but it seems that I am using Java's HTTPClient class internally.

JDK network properties

It was written in here.

sun.net.http.retryPost (default: true) Determines whether unsuccessful HTTP POST requests are automatically resent to the server. In this case, "unsuccessful" means that the server did not send a valid HTTP request or an IOException that occurred.

If the above property is set to false, it will not be resent. However, in the end, if there is no response for n minutes, an error will occur, so it is not a fundamental solution.

Recommended Posts

Stop resending from client to server
Migrate from Java to Server Side Kotlin + Spring-boot
Migrating from Eclipse server function (Tomcat) to Embed Tomcat
Migrate from Transport Client to Rest High Level Client
Minecraft BE server development from PHP to Java
Connect with VS Code from a Windows client to Docker on another server
Changes from Java 8 to Java 11
Sum from Java_1 to 100
Migrate from JUnit 4 to JUnit 5
To connect from Spring to MySQL on virtual server (unsolved)
From Java to Ruby !!
[Android] Uploading images from your device to the server
I want to connect to Heroku MySQL from a client
Try switching from the RHEL environment to the Ubuntu environment Server installation
Sample to create one-time password on server side and client side
Check communication from Android to node.js server with protocol buffers
Moved from iBATIS to MyBatis3
Try Spring Boot from 0 to 100.
Migration from Cobol to JAVA
Switch from slim3-gen to slim3-gen-jsr269
Moving from AWS to PaizaCloud
New features from Java7 to Java8
Migrating from vargrant to docker
Connect from Java to PostgreSQL
Convert from ○ months to ○ years ○ months
How to terminate rails server
Rewriting from applet to application
[Java] Server Client Communication 1 (Unfinished)
Change from SQLite3 to PostgreSQL
From Ineffective Java to Effective Java
How to migrate from JUnit4 to JUnit5
Introduced gRPC client to rails