[
https://issues.apache.org/jira/browse/DIRMINA-1135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17207980#comment-17207980
]
kjhawierhjbasdf commented on DIRMINA-1135:
------------------------------------------
we tried the same setup with using standalone program, and we can see that
connections are getting cleaned up.
{code:java}
// import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;/**
* A server program which accepts requests from clients to capitalize strings.
* When a client connects, a new thread is started to handle it. Receiving
* client data, capitalizing it, and sending the response back is all done on
* the thread, allowing much greater throughput because more clients can be
* handled concurrently.
*/
public class ServerAccpetance { /**
* Runs the server. When a client connects, the server spawns a new thread
to do
* the servicing and immediately returns to listening. The application
limits
* the number of threads via a thread pool (otherwise millions of clients
could
* cause the server to run out of resources by allocating too many threads).
*/
public static void main(String[] args) throws Exception {
try (ServerSocket listener = new ServerSocket(6516)) {
System.out.println("The capitalization server is running...");
ExecutorService pool = Executors.newFixedThreadPool(1000);
while (true) {
pool.execute(new ServerAccpetanc(listener.accept()));
}
}
} private static class ServerAccpetanc implements Runnable {
private Socket socket; ServerAccpetanc(Socket socket) {
this.socket = socket;
} @Override
public void run() {
System.out.println("Connected: " + socket);
try {
Scanner in = new Scanner(socket.getInputStream());
PrintWriter out = new PrintWriter(socket.getOutputStream(),
true);
while (in.hasNextLine()) {
out.println(in.nextLine().toUpperCase());
}
} catch (Exception e) {
System.out.println("Error:" + socket);
} finally {
try {
Thread.sleep(120000);
socket.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Closed: " + socket);
}
}
}
}
{code}
> Connections hanging around in CLOSE_WAIT state, not getting cleaned up
> properly
> -------------------------------------------------------------------------------
>
> Key: DIRMINA-1135
> URL: https://issues.apache.org/jira/browse/DIRMINA-1135
> Project: MINA
> Issue Type: Bug
> Reporter: kjhawierhjbasdf
> Assignee: Jonathan Valliere
> Priority: Major
> Attachments: Screenshot 2020-10-05 at 8.31.37 AM.png, Screenshot
> 2020-10-05 at 9.10.31 AM.png
>
>
> Hello Team,
> We are using Apache MINA(v2.0.21) for tcp tls server implementation.
> I tried with running following operations in loop,
> establishing 200-300 connections
> sending data
> closing connections
> And I observed that, closed connections were getting cleaned up properly.
> In another scenario, We tried configuring AWS ALB and target group, which was
> establishing connection for healthcheck. These were not valid tls
> connections, but only tcp connections. And In this case, we observed that,
> connections were in CLOSE_WAIT state, And these CLOSE_WAITs are hanging
> around far too long. This was impacting our service.
> I did debug the TCP server code, I found that when the sessionClosed method
> is never getting called. Then I tried closing session from sessionIdle
> method, Even after that session.isConnected is showing true, connection is
> not getting closed.
>
> Our product owner is raising concern about, we should be able to avoid denial
> of service attack.
>
> Can you please provide pointers to investigate further.
> Thanks,
> Rupesh Shah
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]