Does TransportClient need to close?

I get a client by the following code,
Code from :
// on startup
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
.addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));
// on shutdown

I put my project on Linux,I always use 'kill pid' to close the project.So the code "client.close()" will not be executed.
Does this waste a lot of connections of es?

Does TransportClient need to be closed?

close() is needed if you are opening multiple (or recreating) clients. It frees up memory resources used by the client. You are correct that if the entire process is killed, close won't affect anything.

1 Like


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.