Unable to connect MongoDB to sink data

I am unable to do the sink connection. can anyone help me on this

my error is.

[2021-06-08 11:31:40,372] INFO MongoSinkTopicConfig values:
        change.data.capture.handler =
        collection =
        database = admin
        delete.on.null.values = false
        document.id.strategy = com.mongodb.kafka.connect.sink.processor.id.strategy.BsonOidStrategy
        document.id.strategy.overwrite.existing = false
        document.id.strategy.partial.key.projection.list =
        document.id.strategy.partial.key.projection.type =
        document.id.strategy.partial.value.projection.list =
        document.id.strategy.partial.value.projection.type =
        document.id.strategy.uuid.format = string
        errors.log.enable = false
        errors.tolerance = none
        field.renamer.mapping = []
        field.renamer.regexp = []
        key.projection.list =
        key.projection.type = none
        max.batch.size = 0
        max.num.retries = 1
        namespace.mapper = com.mongodb.kafka.connect.sink.namespace.mapping.DefaultNamespaceMapper
        namespace.mapper.error.if.invalid = false
        namespace.mapper.key.collection.field =
        namespace.mapper.key.database.field =
        namespace.mapper.value.collection.field =
        namespace.mapper.value.database.field =
        post.processor.chain = [com.mongodb.kafka.connect.sink.processor.DocumentIdAdder]
        rate.limiting.every.n = 0
        rate.limiting.timeout = 0
        retries.defer.timeout = 5000
        topic = test
        value.projection.list =
        value.projection.type = none
        writemodel.strategy = com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneDefaultStrategy
 (com.mongodb.kafka.connect.sink.MongoSinkTopicConfig:361)
[2021-06-08 11:31:40,374] INFO MongoSinkTopicConfig values:
        change.data.capture.handler =
        collection =
        database = admin
        delete.on.null.values = false
        document.id.strategy = com.mongodb.kafka.connect.sink.processor.id.strategy.BsonOidStrategy
        document.id.strategy.overwrite.existing = false
        document.id.strategy.partial.key.projection.list =
        document.id.strategy.partial.key.projection.type =
        document.id.strategy.partial.value.projection.list =
        document.id.strategy.partial.value.projection.type =
        document.id.strategy.uuid.format = string
        errors.log.enable = false
        errors.tolerance = none
        field.renamer.mapping = []
        field.renamer.regexp = []
        key.projection.list =
        key.projection.type = none
        max.batch.size = 0
        max.num.retries = 1
        namespace.mapper = com.mongodb.kafka.connect.sink.namespace.mapping.DefaultNamespaceMapper
        namespace.mapper.error.if.invalid = false
        namespace.mapper.key.collection.field =
        namespace.mapper.key.database.field =
        namespace.mapper.value.collection.field =
        namespace.mapper.value.database.field =
        post.processor.chain = [com.mongodb.kafka.connect.sink.processor.DocumentIdAdder]
        rate.limiting.every.n = 0
        rate.limiting.timeout = 0
        retries.defer.timeout = 5000
        topic = test
        value.projection.list =
        value.projection.type = none
        writemodel.strategy = com.mongodb.kafka.connect.sink.writemodel.strategy.ReplaceOneDefaultStrategy
 (com.mongodb.kafka.connect.sink.MongoSinkTopicConfig:361)
[2021-06-08 11:31:40,374] INFO Cluster created with settings {hosts=[192.168.1.23:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'} (org.mongodb.driver.cluster:71)
[2021-06-08 11:31:42,425] INFO Exception in monitor thread while connecting to server 192.168.1.23:27017 (org.mongodb.driver.cluster:76)
com.mongodb.MongoSocketOpenException: Exception opening socket
        at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70)
        at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:143)
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188)
        at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:144)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
        at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.base/java.net.Socket.connect(Socket.java:609)
        at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:107)
        at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)
        at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
        ... 4 more

@chiragrathod the exception indicates to me the connector cannot reach the configured socket listener. Can you verify through debugging other ways that the connection between the connect worker and the mongo db socket is available? For example, try opening a telnet connection between the connector host and the db host.

1 Like

Hey @rick , this issue is solved. And thanks for your reply. There is an issue in bindIp problem in MongoDB configuration. It is solved now.

2 Likes