# Elasticsearch spark connection for Structured Streaming

**URL:** https://discuss.elastic.co/t/elasticsearch-spark-connection-for-structured-streaming/188225
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [July 1, 2019, 4:49am UTC](https://discuss.elastic.co/t/elasticsearch-spark-connection-for-structured-streaming/188225 "2019-07-01T04:49:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gokul\_Raj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gokul_raj/32/48717_2.png) [@Gokul\_Raj](https://discuss.elastic.co/u/Gokul_Raj)
#### Post date: [July 1, 2019, 4:49am UTC](https://discuss.elastic.co/t/elasticsearch-spark-connection-for-structured-streaming/188225/1 "2019-07-01T04:49:31Z")

</div>

I'm trying to make a connection to elasticsearch from my spark program.  
My elasticsearch host is https and found no connection property for that.  
We are using spark structred streaming Java API and the connection details are as follows,

```auto
		SparkSession spark = SparkSession.builder()
				.config(ConfigurationOptions.ES_NET_HTTP_AUTH_USER, "username")
				.config(ConfigurationOptions.ES_NET_HTTP_AUTH_PASS, "password")
				 .config(ConfigurationOptions.ES_NODES, "my_host_url")
				 .config(ConfigurationOptions.ES_PORT, "9200")
 .config(ConfigurationOptions.ES_NET_SSL_TRUST_STORE_LOCATION,"C:\\certs\\elastic\\truststore.jks")
.config(ConfigurationOptions.ES_NET_SSL_TRUST_STORE_PASS,"my_password") .config(ConfigurationOptions.ES_NET_SSL_KEYSTORE_TYPE,"jks")
				.master("local[2]")
				.appName("spark_elastic").getOrCreate();
		spark.conf().set("spark.sql.shuffle.partitions",2);
		spark.conf().set("spark.default.parallelism",2);

```

And I'm getting the following error

```auto
19/07/01 12:26:00 INFO HttpMethodDirector: I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 10.xx.xxx.xxx failed to respond
19/07/01 12:26:00 INFO HttpMethodDirector: Retrying request
19/07/01 12:26:00 ERROR NetworkClient: Node [10.xx.xxx.xxx:9200] failed (The server 10.xx.xxx.xxx failed to respond); no other nodes left - aborting...
19/07/01 12:26:00 ERROR StpMain: Error
org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot detect ES version - typically this happens if the network/Elasticsearch cluster is not accessible or when targeting a WAN/Cloud instance without the proper setting 'es.nodes.wan.only'
	at org.elasticsearch.hadoop.rest.InitializationUtils.discoverClusterInfo(InitializationUtils.java:344)

```

Probably it's because it tries to initiate connection by http protocol but in my case I need https connection and not sure how to configure that

---

<div class="post-metadata">

### Author: ![Gokul\_Raj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gokul_raj/32/48717_2.png) [@Gokul\_Raj](https://discuss.elastic.co/u/Gokul_Raj)
#### Post date: [July 3, 2019, 7:22am UTC](https://discuss.elastic.co/t/elasticsearch-spark-connection-for-structured-streaming/188225/2 "2019-07-03T07:22:47Z")

</div>

The error happened as spark was not able to locate the truststore file.  
It seems we need to add "file:\" for the path to be accepted.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 31, 2019, 7:33am UTC](https://discuss.elastic.co/t/elasticsearch-spark-connection-for-structured-streaming/188225/3 "2019-07-31T07:33:39Z")

</div>

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