Seeing many open Elasticsearch connections even after using singleton pattern

Hi,

I just the following method for connection creation in ES:

public static Client getClient() {
    if (client == null) {
        synchronized (mutex) {
            settings = 

ImmutableSettings.settingsBuilder().put(CONFIG_CLUSTER_NAME,
CLUSTER_NAME).build();
client = new TransportClient(settings);
for (String address : transportAddress ) {
((TransportClient) client).addTransportAddress(new
InetSocketTransportAddress(address, transportPort));
}
logger.info("Elastic search client initialized");
}
}
logger.info("Returning the existing client");
return client;
}

But for this application, when I ran netstat on that host, I saw many
open connections:

tcp        0      0 ::ffff:*.*.*.*:59380  ::ffff:*.*.*.*:9300   

ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:48829 ::ffff:...:9300
ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:42944 ::ffff:...:9300
TIME_WAIT -
tcp 0 0 ::ffff:...:42838 ::ffff:...:9300
ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:8080 ::ffff:...:57649
ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:55154 ::ffff:...:3306
ESTABLISHED 6552/java
tcp 0 1 ::ffff:...:36889 ::ffff:...:9300
FIN_WAIT1 -
tcp 0 0 ::ffff:...:42829 ::ffff:...:9300
ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:37169 ::ffff:...:9300
TIME_WAIT -
tcp 0 0 ::ffff:...:59390 ::ffff:...:9300
ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:58283 ::ffff:...:9300
TIME_WAIT -
tcp 0 0 ::ffff:...:59383 ::ffff:...:9300
ESTABLISHED 6552/java
tcp 0 0 ::ffff:...:55855 ::ffff:...:9300
TIME_WAIT -
tcp 0 0 ::ffff:...:48823 ::ffff:...:9300
ESTABLISHED 6552/java
tcp 0 1 ::ffff:...:36884 ::ffff:...:9300
FIN_WAIT1 -

I have removed the ip with .... But there are many more open
connections than this.

Questions:
-> How do I manually go and close all these connections?
-> Is there any mistake in connection creation?
-> Sometimes, even if ES is running and connection is also created, it
doesn't get any response. After restarting the application, it returns
result for the same query. How should I analyze this?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0d751233-ad0d-4c70-bdd0-ca3234b28836%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.