10 Replies Latest reply on Feb 4, 2019 5:09 AM by Daniel Teixeira

    Connecting to MongoDB through hosted mongosqld

    Jonathan Tushman

      Hi guys -- this is a x-post from Stack Overflow:  amazon ec2 - Connecting to MongoDB through mongosqld (BI Connector) - Stack Overflow

       

      I'm having issues getting the Mongo BI Connector (mongosqld) working/configured

      I have it running on a amazon linux ec2 box. I am able to connect via mongo to the mongo server, and I was able to generate the schema from the box with mongodrdl

      But when I try to connect remotely through the connector I get the following error:

      connection accepted from 108.20.YYY.XXX:53793, but could not initialize: unable to connect to MongoDB: no servers available: server selection failed: context deadline exceeded

      I have tried a bunch of configurations, all give similar errors.  So for now I have simplified the execution to:

       

      `mongosqld --schema=schema.drdl --addr=0.0.0.0:3307`

       

          [ec2-user@ip-10-0-0-147 elt]$ mongosqld --schema=schema.drdl --addr=0.0.0.0:3307

          2017-11-29T03:27:36.147+0000 I CONTROL    [initandlisten] mongosqld starting: version=v2.3.1 pid=24455 host=ip-10-0-0-147

          2017-11-29T03:27:36.147+0000 I CONTROL    [initandlisten] git version: fa3535342a4c5abe36e3cc28a2ecf72864dfc6fe

          2017-11-29T03:27:36.147+0000 I CONTROL    [initandlisten] OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013

          2017-11-29T03:27:36.147+0000 I CONTROL    [initandlisten] options: {schema: {path: "schema.drdl"}, net: {bindIp: [0.0.0.0]}}

          2017-11-29T03:27:36.147+0000 I CONTROL    [initandlisten] ** WARNING: Access control is not enabled for mongosqld.

          2017-11-29T03:27:36.147+0000 I CONTROL    [initandlisten]

          2017-11-29T03:27:36.159+0000 I NETWORK    [initandlisten] waiting for connections at [::]:3307

          2017-11-29T03:27:36.159+0000 I NETWORK    [initandlisten] waiting for connections at /tmp/mysql.sock

          2017-11-29T03:27:56.199+0000 E NETWORK    [initandlisten] connection accepted from 108.20.YYY.XXX:53793, but could not initialize: unable to connect to MongoDB: no servers available: server selection failed: context deadline exceeded

       

       

      Note: I have this working end-to-end when all services are on the same machine.

       

       

      Can anyone shed some light?! 

       

       

      Thanks!

        • 1. Re: Connecting to MongoDB through hosted mongosqld
          Tom W

          Are you able to connect using a mongo client remotely?

          • 2. Re: Connecting to MongoDB through hosted mongosqld
            Jonathan Tushman

            Yup.  can connect directly from the ec2 box to my mongodb instance by the mongo client.

             

            I was also able to generate the schema from that box.

            • 3. Re: Connecting to MongoDB through hosted mongosqld
              Tom W

              I was actually asking if you're able to connect remotely using the mongo client i.e. on your PC and not the ec2 instance? I'm trying to figure out if the problem is Tableau remotely or your remote connection to the ec2 instance in general.

              • 4. Re: Connecting to MongoDB through hosted mongosqld
                Jonathan Tushman

                yup -- we can connect to the mongo instance from my pc (and others)

                • 5. Re: Connecting to MongoDB through hosted mongosqld
                  Tom W

                  Do you call this mono connector outside of Tableau. I.e. the log output you show in your original post - is that from a console session you have to initiate before opening Tableau, or is this being generated in a logfile after you've connected in Tableau?

                   

                  I'd take a look and see if you can increase the timeout in the configuration for your connector.

                  • 6. Re: Connecting to MongoDB through hosted mongosqld
                    Jonathan Tushman

                    those logs are from the running mongosqld on the ec2 box.

                     

                    The topography is as following

                     

                    [ hosted mongo] <-->  [ec2 box running mongosqld] <--> [client boxes]

                     

                    so that last message:

                     

                    connection accepted from 108.20.YYY.XXX:53793, but could not initialize: unable to connect to MongoDB: no servers available: server selection failed: context deadline exceeded

                     

                    happens when the i attempt a connnection from tableau to the mongosqld service

                    • 7. Re: Connecting to MongoDB through hosted mongosqld
                      Tom W

                      "those logs are from the running mongosqld on the ec2 box."

                       

                      So the "context deadline exceeded" error message is in the logs on the ec2 box but it is triggered by the client machine, in this case the connection from Tableau?

                       

                      Based on that, I'm really not sure how this could be caused by Tableau specifically as my take on it is that the ec2 box cannot make the connection to the MongoDB.

                      If I was to guess, I think the connection is timing out before it has a chance to return back to the Tableau connection dialog. Just curious > what happens on the Tableau side? You enter the server, username, password - what's the error you get in the Tableau dialog?

                      I'd try and see if you can increase the timeout on the mongo connector on the ec2 instance. Failing that, maybe there's a way to increase the timeout from the Tableau side, but I can only imagine that's something you have to do through a config file or registry edit. If you haven't created a case with Tableau Support yet, I'd recommend you do that as they might be able to provide some more info on that - unfortunately I don't know how to do it, let alone if it's even possible.

                      • 8. Re: Connecting to MongoDB through hosted mongosqld
                        Matt Shoemaker

                        Check that your SSL .pem file is valid and regenerate if necessary.  I had a similar problem running mongodrdl.exe.  Can you run mongodrdl on the same machine using the same .pem file?

                        • 9. Re: Connecting to MongoDB through hosted mongosqld
                          Daniel Teixeira

                          Hello,

                          I think I am having exactly the same problem.

                           

                          I am able to make Tableau work with my local database (that does not require authentication), but when I try to connect Tableau to a remote database with authentication I get an error:

                           

                          The schema extraction works perfectly fine on the remote database :

                           

                          mongodrdl --host [MY-HOSTNAME:PORT] --username [MY-USERNAME] --password [MY-PASSWORD] --db [MY-DB] --collection [collection] --authenticationDatabase [MY-DB] --out schema.drdl

                           

                          But when I try to access with mongosqld / Tableau I get an error :

                           

                          My command is the following :

                          1. mongosqld.exe --mongo-uri mongodb://[MY-HOSTNAME:PORT] -u [MY-USERNAME] -p  [MY-PASSWORD] --auth --mongo-ssl --schema schema.drdl

                           

                          I also  tried to pass the databasename like this:

                          1. mongosqld.exe --mongo-uri mongodb://[MY-HOSTNAME:PORT] -u [MY-USERNAME] -p  [MY-PASSWORD] --auth --mongo-authenticationSource [MY-DB] --mongo-ssl --schema schema.drdl

                           

                          But I keep receiving this error when I try to login with Tableau and no way to connect

                           

                          2019-01-24T18:46:58.650+0100 I CONTROL    [initandlisten] mongosqld starting: version=v2.9.0 pid=4868 host=pc-01623

                          2019-01-24T18:46:58.685+0100 I CONTROL    [initandlisten] git version: d8cbef70c1e612d299f120dd997b3872ab32a679

                          2019-01-24T18:46:58.685+0100 I CONTROL    [initandlisten] OpenSSL version OpenSSL 1.0.2n-fips  7 Dec 2017 (built with OpenSSL 1.0.2o  27 Mar 2018)

                          2019-01-24T18:46:58.685+0100 I CONTROL    [initandlisten] options: {schema: {path: "schema.drdl"}, security: {enabled: true}, mongodb: {net: {uri: "*********", ssl: {enabled: true, minimumTLSVersion: "TLS1_1"}, auth: {username: "********", password: "<protected>", source: "*****"}}}}

                          2019-01-24T18:46:58.691+0100 I NETWORK    [initandlisten] waiting for connections at 127.0.0.1:3307

                          2019-01-24T18:47:21.231+0100 E NETWORK    [initandlisten] connection accepted from 127.0.0.1:58863, but could not initialize: unable to connect to MongoDB: no servers available: server selection failed: context deadline exceeded

                          • 10. Re: Connecting to MongoDB through hosted mongosqld
                            Daniel Teixeira

                            Finally it worked for me by generating a self-signed certificate and adding a configuration file.

                            I call the service like this: mongosqld.exe --config mongosqld.conf

                             

                            Then on the interface of tableau connection to mongodb bi connector, server: localhost port: 3307  with same <USERNAME> and <PASSWORD> without selecting SSL option

                             

                             

                            mongosqld.conf file:

                             

                             

                             

                            systemLog:

                             

                            #  logAppend: false

                             

                            #  path: mongosqld.log

                             

                               verbosity: 5

                             

                              

                             

                            security:

                             

                               defaultSource: <DATABASE-NAME>

                             

                               enabled: true

                             

                              

                             

                            mongodb:

                             

                              net:

                             

                                uri: "<HOSTNAME>:<PORT>"

                             

                                auth:

                             

                                  username: "<USERNAME>"

                             

                                  password: "<PASSWORD>"

                             

                                  mechanism: "SCRAM-SHA-1"

                             

                              

                             

                            net:

                             

                              bindIp: "localhost"

                             

                              port: 3307

                             

                              ssl:

                             

                                mode: "allowSSL"

                             

                                PEMKeyFile: "test.pem"

                             

                              

                             

                            schema:

                             

                              path: "schema.drdl"