2

I am running a siddhi application which listens to events and writes them into a mongodb instance running on a remote machine. The mongo db instance has basic authentication setup (username, password). I tried connecting to the mongodb instance and writing events into a collection, in the logs I am able to see that wso2 could connect to the remote instance

[2019-05-17 12:30:25,753]  INFO {org.mongodb.driver.cluster} - Cluster created with settings {hosts=[10.x.x.xxx:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[2019-05-17 12:30:25,763]  INFO {org.mongodb.driver.cluster} - Cluster created with settings {hosts=[10.x.x.xxx:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[2019-05-17 12:30:25,765]  INFO {org.wso2.carbon.siddhi.editor.core.internal.WorkspaceDeployer} - Siddhi App xxxxxxxxxx successfully deployed.
[2019-05-17 12:30:26,017]  INFO {org.mongodb.driver.connection} - Opened connection [connectionId{localValue:430, serverValue:1009}] to 10.x.x.xxx:27017
[2019-05-17 12:30:26,018]  INFO {org.mongodb.driver.connection} - Opened connection [connectionId{localValue:432, serverValue:1010}] to 10.x.x.xxx:27017

When I try to write into the mongodb, I get the following error

[2019-05-17 12:30:35,334] ERROR {org.wso2.siddhi.core.SiddhiAppRuntime} - Error starting Siddhi App 'IntegrationTesting', triggering shutdown process. Error on 'IntegrationTesting'. Error in retrieving collection names from the database 'IntegrationTesting' : Command failed with error 13: 'command listCollections requires authentication' on server 10.x.x.xxx:27017. The full response is { "ok" : 0.0, "errmsg" : "command listCollections requires authentication", "code" : 13, "codeName" : "Unauthorized" }

I tried adding the user name and password in the siddhi app @store() and also tried adding a data source in the /conf/worker/deployment.yaml. In both the cases I get the same error.

Please assist.

Regards and thanks,

Chaithanya Kumar.S

Data Scientist - Koinearth.

SCK
  • 41
  • 4

1 Answers1

1

How did you configure the credentials, MongoDB extension expects username and password to be inserted into the URI.

@Store(type="mongodb",mongodb.uri="mongodb://admin:admin@localhost/Foo")

https://siddhi-io.github.io/siddhi-store-mongodb/api/1.1.0/

Update: Read permission on adminDB and Write permission is required

Niveathika
  • 1,319
  • 2
  • 8
  • 17
  • I have mentioned that I tried that way, it does not work. I get the same error [2019-05-17 12:30:35,334] ERROR {org.wso2.siddhi.core.SiddhiAppRuntime} - Error starting Siddhi App 'IntegrationTesting', triggering shutdown process. Error on 'IntegrationTesting'. Error in retrieving collection names from the database 'IntegrationTesting' : Command failed with error 13: 'command listCollections requires authentication' on server 10.x.x.xxx:27017. The full response is { "ok" : 0.0, "errmsg" : "command listCollections requires authentication", "code" : 13, "codeName" : "Unauthorized" } – SCK May 20 '19 at 06:42
  • Have you opened MongoDB to accept connections from a remote host? – Niveathika May 20 '19 at 07:09
  • Yes, I am able to connect to the same mongodb instance from my terminal. – SCK May 20 '19 at 07:47
  • Hi @Niveathika, I have tried the way you mentioned in your answer,I still get the same error. I have also verified if the user has permissions on mongo to write, there is no issue on the mongo side. I also tried using the latest jar for mongo from your website, no luck there. Can you help with this? – SCK May 20 '19 at 10:07
  • At the initialization, the extension checks the available collection and creates a collection for siddhi event table if not present. For this, it seems the user needs permissions for admin db. – Niveathika May 21 '19 at 04:35