# Unable to configure MongoSinkConnector of Kafka-connect using cURL command

**URL:** <https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054>\
**Category:** Managed Connectors\
**Created:** [20 January 2023 08:35 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054 "2023-01-20T08:35:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 08:35 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/1 "2023-01-20T08:35:23Z")

</div>

I want to configure MongoSinkConnector to read the data from Kafka topics and load the same to MongoDB Collection. I have TLS enabled on my Mongo DB (AWS Document DB) cluster. I have ca-bundle.pem file for accessing the Mongo Cluster. I have created a new keystore on my local machine, added the ca-bundle.pem file to the newly created keystore. Mounted the keystore to the kafka-connect docker container by specifying the keystore binding in kafka-connect volumes in docker-compose file.

volumes:  
- ./plugins:/tmp/connect-plugins:Z  
- ./mykeystore.jks:/home/appuser/mykeystore.jks

I have also specified few env variables in kafka-connect docker container env variables as shown below:

CONNECT\_SSL\_TRUSTSTORE\_TYPE: ssl.truststore.type=JKS  
CONNECT\_SSL\_TRUSTSTORE\_LOCATION: /home/appuser/mykeystore.jks  
CONNECT\_SSL\_TRUSTSTORE\_PASSWORD: mystorepass  
CONNECT\_KAFKA\_OPTS: “-Djavax.net.ssl.trustStore=/home/appuser/mykeystore.jks   
-Djavax.net.ssl.trustStorePassword=mystorepass   
-Djavax.net.ssl.keyStore=/home/appuser/mykeystore.jks   
-Djavax.net.ssl.keyStorePassword=mystorepass”  
CONNECT\_KAFKA\_JMX\_OPTS: “-Djavax.net.ssl.trustStore=/home/appuser/mykeystore.jks   
-Djavax.net.ssl.trustStorePassword=mystorepass”  
CONNECT\_JAVA\_OPTS: “-Djavax.net.debug=ssl:handshake”

I am then using cURL command to configure the MongoSinkConnector with Kafka-connect as shown below:

curl -X POST   
-H “Content-Type: application/json”   
–data ‘{“name”: “mongo-sink”,  
“config”: {  
“connector.class”:“com.mongodb.kafka.connect.MongoSinkConnector”,  
“topics”:“KAFKA\_TEST.wireless.wholesale.whapi.activateSubscription”, “connection.uri”:“mongodb://username:pwd@aws-docdb-cluster-hostname:5000/?tls=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false”,  
“key.converter”: “org.apache.kafka.connect.storage.StringConverter”,  
“value.converter”: “org.apache.kafka.connect.json.JsonConverter”,  
“value.converter.schemas.enable”: false,  
“database”:“KAFKA\_TEST”,  
“collection”:“wireless.activateSubscription”  
}  
}’   
[http://localhost:8083/connectors](http://localhost:8083/connectors) -w “\n”

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 09:28 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/2 "2023-01-20T09:28:28Z")

</div>

@mmuehlbeyer @dtroiano Could anyone of you please help me with this issue, I got stuck with these from past 1 week. I need to resolve this asap as it is a blocker for all my work.

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 09:55 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/3 "2023-01-20T09:55:29Z")

</div>

any errors?

what does

`curl http://localhost:8083/connectors/mongo-sink/status`

say?

Best,  
Michael

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 10:15 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/4 "2023-01-20T10:15:22Z")

</div>

@mmuehlbeyer I am getting below error while executing the curl command. I can see this error in my kafka-connect docker container logs.

INFO Exception in monitor thread while connecting to server [docdb-2022-07-07-19-03-05.cluster-csac2qtnbivs.us-west-2.docdb.amazonaws.com:5000](http://docdb-2022-07-07-19-03-05.cluster-csac2qtnbivs.us-west-2.docdb.amazonaws.com:5000) (org.mongodb.driver.cluster)  
com.mongodb.MongoSocketException: [docdb-2022-07-07-19-03-05.cluster-csac2qtnbivs.us-west-2.docdb.amazonaws.com](http://docdb-2022-07-07-19-03-05.cluster-csac2qtnbivs.us-west-2.docdb.amazonaws.com): Name or service not known

Here “docdb-2022-07-07-19-03-05.cluster-csac2qtnbivs.us-west-2.docdb.amazonaws.” is the Document DB (Mongo) host name

I am unable to create the connector.

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 10:22 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/5 "2023-01-20T10:22:43Z")

</div>

where is your kafka cluster running?

aws? confluent cloud? onprem?

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 10:27 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/6 "2023-01-20T10:27:55Z")

</div>

my kafka-cluster is running on my local system and Document DB (My mongo db) cluster is on AWS. I have ca-bundle.pem file which I usually use to access Document DB (My mongo db) from my local machine.

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 10:41 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/7 "2023-01-20T10:41:20Z")

</div>

I see  
seems network related

your kafka-connect can’t resolve the endpoint of your mongo db instance.  
I guess there is there a proxy or firewall in place right?

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 10:44 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/8 "2023-01-20T10:44:54Z")

</div>

I am on VPN. But from my local machine (where I have all of my docker containers running) am able to access that doc db cluster. Hence networking team confirmed that there is no blockers in accessing document db from local.

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 10:54 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/9 "2023-01-20T10:54:12Z")

</div>

ok so it might be related to docker

is it possible to ping or curl the host from within the docker container?

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 11:16 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/10 "2023-01-20T11:16:46Z")

</div>

@mmuehlbeyer  
ping “mongodb (doc db) hostname” → This doesn’t work in my local machine and docker container. But I am able to list databases/collections available in MongoDB from my local machine.  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/b/b9fdd281fbd628337a7d5f2f15fef3f6562bb38c.png)

Below image while pinging Document DB host from local machine

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/8/8a2e93a84b40fb0e766561df7aadd46275767339.png)

Below image while pinging Doc DB host from kafka-connect docker container

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/6/69e37bd9002911beeafb882532a162a6747a25e5.png)

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 12:07 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/11 "2023-01-20T12:07:19Z")

</div>

so I think it’s related to the names resolution from within the container.

from my running container I could at least resolve the name.

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 12:12 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/12 "2023-01-20T12:12:51Z")

</div>

@mmuehlbeyer yes, I added an entry with in /etc/hosts file inside docker container. It is now able to resolve the host name,

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/1/128993051e6e39dd4c7efaa55c3be9782998a197.png)

But when I execute the curl command to create MongoSinkConnector am getting the below error.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/8/8e3077175a4a4d47a151fee57dc08453f8754c64.png)

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 12:26 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/13 "2023-01-20T12:26:11Z")

</div>

ok so one step further 🙂

does your mongodb cluster enforce tls connections?

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 12:34 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/14 "2023-01-20T12:34:25Z")

</div>

Yes, MongoDB cluster has TLS enabled. I have the certificate (.pem file) required to access this cluster. Hence I have done the below steps:

1. I have created a keystore on my host machine (mykeystore.jks)
2. I have converted .pem to .crt file (sudo mycert.pem \>\> mycert.crt)
3. Added this .crt file to mykeystore.jks
4. In my docker compose file, Under the volumes of my “kafka-connect” docker container I have specified to mount this keystore file to a folder inside the kafka-connect docker container.

Even after following all these I still get the same error “Unable to find the valid certification path to the requested target”

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 12:40 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/15 "2023-01-20T12:40:57Z")

</div>

ok I see.

though all of your provided configs are for the kafka tls part.  
I can’t see any config related to mongodb tls/ssl config.

a monodb tls config should be like the following , right?

```auto
"connection.uri":"mongodb://hostname1.domain.name:27017,pre-hostname2.domain.name:27017/?ssl=true"

```

best,  
michael

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 12:54 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/16 "2023-01-20T12:54:44Z")

</div>

yes, I have my mongodb connection uri specified in the curl command.

curl -X POST  
-H “Content-Type: application/json”  
–data ‘{“name”: “mongo-sink”,  
“config”: {  
“connector.class”:“com.mongodb.kafka.connect.MongoSinkConnector”,  
“topics”:“KAFKA\_TEST.wireless.wholesale.whapi.activateSubscription”, **“connection.uri”:“mongodb://username:pwd@aws-docdb-cluster-hostname:5000/?tls=true&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false”,**  
“key.converter”: “org.apache.kafka.connect.storage.StringConverter”,  
“value.converter”: “org.apache.kafka.connect.json.JsonConverter”,  
“value.converter.schemas.enable”: false,  
“database”:“KAFKA\_TEST”,  
“collection”:“wireless.activateSubscription”  
}  
}’  
[http://localhost:8083/connectors](http://localhost:8083/connectors) -w “\n”

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 12:58 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/17 "2023-01-20T12:58:02Z")

</div>

I see though there is no config related to ssl/tls

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 13:01 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/18 "2023-01-20T13:01:55Z")

</div>

Could you please elaborate on what is “config related to ssl/tls” ?

How to identify which path does the kafka-connect refer to w.r.t certification path as error in the logs says “Unable to identify the valid certification path to the requested target”

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [20 January 2023 13:05 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/19 "2023-01-20T13:05:25Z")

</div>

I think you have to tell the mongodb connector  
to use ssl for connecting to your mongo endpoint

need to check the docs by myself

---

<div class="post-metadata">

**Author:** ![Vaishnavi](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@Vaishnavi](https://forum.confluent.io/u/Vaishnavi)\
**Post date:** [20 January 2023 13:12 UTC](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054/20 "2023-01-20T13:12:49Z")

</div>

> [@Vaishnavi](#):
>
> How to identify which path does the kafka-connect refer to w.r.t certification path as error in the logs says “Unable to identify the valid certification path to the requested target”

How about this query ? Any clue how to find this out. I have enabled ssl debugging but unable to find anything in kafka-connect container logs.

[Next page](https://forum.confluent.io/t/unable-to-configure-mongosinkconnector-of-kafka-connect-using-curl-command/7054.md?page=2)
