# Java Client slower than http

**URL:** <https://discuss.elastic.co/t/java-client-slower-than-http/2517>\
**Category:** Elasticsearch\
**Created:** [June 11, 2015, 8:02pm UTC](https://discuss.elastic.co/t/java-client-slower-than-http/2517 "2015-06-11T20:02:46Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![prateek](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@prateek](https://discuss.elastic.co/u/prateek)\
**Post date:** [June 11, 2015, 8:02pm UTC](https://discuss.elastic.co/t/java-client-slower-than-http/2517/1 "2015-06-11T20:02:46Z")

</div>

We are currently using TransportClient and observing that query response times are considerably slower than using http (through sense plugin). Below is code snippet for initializing TransportClient:

```
> void createClient(Map<String, String> props) {
    Settings settings = ImmutableSettings.settingsBuilder().put(props).build();
    transportClient = new TransportClient(settings);
    String[] hosts = getTransportHosts().split(",");
    for (String host : hosts) {
        int index = host.indexOf(COLON);
        String hostname = host.substring(0, index);
        String port = host.substring(index + 1);
        transportClient.addTransportAddress(new InetSocketTransportAddress(hostname.trim(), Integer.parseInt(port.trim())));
    }
}

Map<String, String> createClientConfigSettings() {
    Map<String, String> clientProperties = new HashMap<>();
    clientProperties.put(CLUSTER_NAME_PROPERTY, getClusterName());
    clientProperties.put("client.transport.ping_timeout", "10s");
    clientProperties.put("client.transport.nodes_sampler_interval", "10s");
    String nodeName = processInstanceName();
    clientProperties.put("node.name", nodeName);
    return clientProperties;
}

```

Please advise.

Thanks,  
Prateek

---

_[View the full topic](https://discuss.elastic.co/t/java-client-slower-than-http/2517)._
