sandialabs/scot

Mongo attempts to connect on port 27017 even if you specify a different port

ghub2015 opened this issue · 4 comments

OS: Ubuntu Server 14.04

If you modify /opt/sandia/webapps/scot3/scot.conf to utilize an alternative port for Mongo (let's say port 27021 for this example), even though SCOT acknowledges the alternative port, SCOT still tries to connect to the MongoDB using port 27017.

Edit: Here is the config snippet from scot.conf:

                    'database' => {
                                    'write_safety' => 1,
                                    'port' => 27021,
                                    'db_name' => 'scotng-prod',
                                    'host' => 'mongodb://<YourMongoDBHostname>',
                                    'user' => 'scot',
                                    'pass' => 'password'
                                  }

Here is the output from /var/log/scot.prod.log (I added ** for emphasis, since I can't add bolding inside code tags)


2016/02/19 16:13:13 [2462]        Mongo.pm:  676 Retrieving one document
2016/02/19 16:13:13 [2462]        Mongo.pm:   95 ---- Mongo client connection build ---
2016/02/19 16:13:13 [2462]        Mongo.pm:   96 ---- host:    mongodb://<YourMongoDBHostname>
2016/02/19 16:13:13 [2462]        Mongo.pm:   97 ---- port:    **27021**
2016/02/19 16:13:13 [2462]        Mongo.pm:   98 ---- name:    scotng-prod
2016/02/19 16:13:13 [2462]        Mongo.pm:   99 ---- user:    scot
2016/02/19 16:13:13 [2462]        Mongo.pm:  776 mongodb://<YourMongoDBHostname> Reading documents matching $VAR1 = {'collection' => 'users','all' => 1,'match_ref' => {'username' => 'admin'}};
2016/02/19 16:13:52 [2432] DefaultHelpers.pm:   90 MongoDB::SelectionError: No readable server available for matching read preference primary. MongoDB server status:
Topology type: Single; Member status:
  <YourMongoDBHostname>:**27017** (type: Unknown, error: MongoDB::NetworkError: Could not connect to '<YourMongoDBHostname>:**27017**': Connection timed out )
2016/02/19 16:13:52 [2432]  EPLRenderer.pm:   50 Template "exception.development.html.ep" not found
2016/02/19 16:13:52 [2432]  EPLRenderer.pm:   50 Template "exception.html.ep" not found
2016/02/19 16:13:52 [2432]  EPLRenderer.pm:   38 Rendering template "mojo/debug.html.ep"
2016/02/19 16:13:52 [2432]  EPLRenderer.pm:   38 Rendering template "mojo/menubar.html.ep"
2016/02/19 16:13:58 [2445] DefaultHelpers.pm:   90 MongoDB::SelectionError: No readable server available for matching read preference primary. MongoDB server status:
Topology type: Single; Member status:
  <YourMongoDBHostname>:**27017** (type: Unknown, error: MongoDB::NetworkError: Could not connect to '<YourMongoDBHostname>:**27017**': Connection timed out )

The MongoDB::Client has changed and the port field in the config isn't really used anymore. You can change your config to the following:

host => 'mongodb://<yourHost>:<yourPort>'

and everything should work for you.

See http://search.cpan.org/~friedo/MongoDB-0.502.0/lib/MongoDB/MongoClient.pm#host
for more connection option information.

Sorry about the confusion....

Hi Todd, thanks for the followup.

Accordingly, the value of the Port field is therefore irrelevant, correct?
(i.e., we could set it to 0 if we wanted to, for readability/reduce confusion?)

Yes, you are correct.


todd.bruner@gmail.com

On Mon, Feb 22, 2016 at 10:38 AM, ghub2015 notifications@github.com wrote:

Hi Todd, thanks for the followup.

Accordingly, the value of the Port field is therefore irrelevant, correct?

(i.e., we could set it to 0 if we wanted to, for readability/reduce
confusion?)


Reply to this email directly or view it on GitHub
#31 (comment).

OK, thanks again.