mongo: getting lots of connections when no backend is talking to db - mongodb

I just created a mongo replicated setup with two instances. The logs show a lot of connections starting and ending every second. The logs are below. Any idea why there are so many connections when I don't have any servers talking to the DB? I'm also confused why the port the connections are coming from keep increasing.
Primary Mongo Instance
$ tail /log/mongod.log
2015-02-08T21:46:40.679+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43833 #58 (6 connections now open)
2015-02-08T21:46:40.680+0000 [conn58] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:47:05.416+0000 [conn10] end connection <local machine private IP from EC2>:43719 (5 connections now open)
2015-02-08T21:47:05.416+0000 [conn13] end connection <local machine private IP from EC2>:43724 (4 connections now open)
2015-02-08T21:47:10.699+0000 [conn58] end connection <local machine private IP from EC2>:43833 (3 connections now open)
2015-02-08T21:47:10.700+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43835 #59 (4 connections now open)
2015-02-08T21:47:10.702+0000 [conn59] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:47:40.720+0000 [conn59] end connection <local machine private IP from EC2>:43835 (3 connections now open)
2015-02-08T21:47:40.723+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43836 #60 (4 connections now open)
2015-02-08T21:47:40.724+0000 [conn60] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
Secondary Mongo Instance
$ tail /log/mongod.log
2015-02-08T21:46:39.732+0000 [conn285] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:46:59.877+0000 [initandlisten] connection accepted from <local machine elastic IP from EC2>:42568 #286 (4 connections now open)
2015-02-08T21:46:59.881+0000 [conn286] end connection <local machine elastic IP from EC2>:42568 (3 connections now open)
2015-02-08T21:47:05.424+0000 [conn191] end connection <local machine private IP from EC2>:44756 (2 connections now open)
2015-02-08T21:47:09.750+0000 [conn285] end connection <local machine private IP from EC2>:43873 (1 connection now open)
2015-02-08T21:47:09.752+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43874 #287 (2 connections now open)
2015-02-08T21:47:09.753+0000 [conn287] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
2015-02-08T21:47:39.772+0000 [conn287] end connection <local machine private IP from EC2>:43874 (1 connection now open)
2015-02-08T21:47:39.774+0000 [initandlisten] connection accepted from <local machine private IP from EC2>:43875 #288 (2 connections now open)
2015-02-08T21:47:39.775+0000 [conn288] authenticate db: local { authenticate: 1, nonce: "xxx", user: "__system", key: "xxx" }
I am also a bit confused why the elastic IP is being used in some cases (see secondary log). I assume using the public IP would cause me to get charged by AWS?

The connections that are coming every 30 seconds are the heartbeat threads, coming from the other replica set member to make sure this member is still alive and healthy. They use whatever IP is in your replica set configuration.
The connection using the public IP seems to end its connection very quickly. Turn up your log level and figure out what it's doing?

Related

Can't connect to mongodb with self-signed certificate, mongodb in docker container

I have created a docker container with a mongodb image. I created a self-signed certificate for the secure connections to the database following this guide.
I started trying to make a connection with these certificates where rootCA.pem is the self-signed certificate of the computer that will become the certifier, in this case the same. And mongodb.pem is the .key of the server + the .crt.
root#8bc7b8cd6a0d:/# mongo --tls --tlsCAFile /data/db/certs/rootCA.pem --tlsCertificateKeyFile /data/db/certs/mongodb.pem --host 172.17.0.2:27017
MongoDB shell version v4.2.6
connecting to: mongodb://172.17.0.2:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-04-29T09:21:21.255+0000 E QUERY [js] Error: couldn't connect to server 172.17.0.2:27017, connection attempt failed: SocketException: stream truncated :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-04-29T09:21:21.259+0000 F - [main] exception: connect failed
2020-04-29T09:21:21.259+0000 E - [main] exiting with code 1
root#8bc7b8cd6a0d:/#
root#8bc7b8cd6a0d:/# mongo --tls --tlsCAFile /data/db/certs/rootCA.pem --tlsCertificateKeyFile /data/db/certs/mongodb.pem
MongoDB shell version v4.2.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-05-05T19:39:52.308+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: stream truncated :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-05-05T19:39:52.358+0000 F - [main] exception: connect failed
2020-05-05T19:39:52.359+0000 E - [main] exiting with code 1
root#8bc7b8cd6a0d:/#
The certificates are stored in the following directory, which is in a volume to the container to store the data from the database.
root#auzal-virtual-machine:/opt/mimongo# ls certs
mongodb.crt mongodb.csr mongodb.key mongodb.pem rootCA.key rootCA.pem rootCA.srl
Finally the configuration file is structured in the following way, this file is a copy of the original, I say this in case you see that the name is different from normal:
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
ssl:
mode: requireSSL
PEMKeyFile: /data/db/certs/mongodb.pem
CAFile: /data/db/certs/rootCA.pem
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
I don't know why I get that error, could it be that I am interpreting something wrong with the certificates and not indicating the correct one? What is the error I receive?
reviewing the logs with a statement within the database I get the following error, however this ability in the main configuration file:
Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support.
The authentication you see is from an administrator user but without a certificate
"2020-05-06T21:46:58.796+0000 I NETWORK [conn3] end connection 127.0.0.1:56360 (0 connections now open)",
"2020-05-06T21:47:02.052+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56362 #4 (1 connection now open)",
"2020-05-06T21:47:02.053+0000 I NETWORK [conn4] Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support. Ending connection from 127.0.0.1:56362 (connection id: 4)",
"2020-05-06T21:47:02.053+0000 I NETWORK [conn4] end connection 127.0.0.1:56362 (0 connections now open)",
"2020-05-06T21:47:08.628+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56364 #5 (1 connection now open)",
"2020-05-06T21:47:08.629+0000 I NETWORK [conn5] Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support. Ending connection from 127.0.0.1:56364 (connection id: 5)",
"2020-05-06T21:47:08.629+0000 I NETWORK [conn5] end connection 127.0.0.1:56364 (0 connections now open)",
"2020-05-06T21:47:11.815+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56366 #6 (1 connection now open)",
"2020-05-06T21:47:11.816+0000 I NETWORK [conn6] Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support. Ending connection from 127.0.0.1:56366 (connection id: 6)",
"2020-05-06T21:47:11.817+0000 I NETWORK [conn6] end connection 127.0.0.1:56366 (0 connections now open)",
"2020-05-06T21:47:21.515+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56368 #7 (1 connection now open)",
"2020-05-06T21:47:21.515+0000 I NETWORK [conn7] Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support. Ending connection from 127.0.0.1:56368 (connection id: 7)",
"2020-05-06T21:47:21.516+0000 I NETWORK [conn7] end connection 127.0.0.1:56368 (0 connections now open)",
"2020-05-06T21:50:17.250+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56374 #8 (1 connection now open)",
"2020-05-06T21:50:17.251+0000 I NETWORK [conn8] Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support. Ending connection from 127.0.0.1:56374 (connection id: 8)",
"2020-05-06T21:50:17.251+0000 I NETWORK [conn8] end connection 127.0.0.1:56374 (0 connections now open)",
"2020-05-06T21:51:48.008+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56396 #9 (1 connection now open)",
"2020-05-06T21:51:48.009+0000 I NETWORK [conn9] received client metadata from 127.0.0.1:56396 conn9: { application: { name: \"MongoDB Shell\" }, driver: { name: \"MongoDB Internal Client\", version: \"4.2.6\" }, os: { type: \"Linux\", name: \"Ubuntu\", architecture: \"x86_64\", version: \"18.04\" } }",
"2020-05-06T21:51:54.405+0000 I NETWORK [conn9] end connection 127.0.0.1:56396 (0 connections now open)",
"2020-05-06T21:52:03.681+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56402 #10 (1 connection now open)",
"2020-05-06T21:52:03.682+0000 I NETWORK [conn10] received client metadata from 127.0.0.1:56402 conn10: { application: { name: \"MongoDB Shell\" }, driver: { name: \"MongoDB Internal Client\", version: \"4.2.6\" }, os: { type: \"Linux\", name: \"Ubuntu\", architecture: \"x86_64\", version: \"18.04\" } }",
"2020-05-06T21:52:03.682+0000 I SHARDING [conn10] Marking collection admin.system.users as collection version: <unsharded>",
"2020-05-06T21:52:03.776+0000 I ACCESS [conn10] SASL SCRAM-SHA-256 authentication failed for admin on admin from client 127.0.0.1:56402 ; AuthenticationFailed: SCRAM authentication failed, storedKey mismatch",
"2020-05-06T21:52:03.786+0000 I NETWORK [conn10] end connection 127.0.0.1:56402 (0 connections now open)",
"2020-05-06T21:52:16.138+0000 I NETWORK [listener] connection accepted from 127.0.0.1:56404 #11 (1 connection now open)",
"2020-05-06T21:52:16.139+0000 I NETWORK [conn11] received client metadata from 127.0.0.1:56404 conn11: { application: { name: \"MongoDB Shell\" }, driver: { name: \"MongoDB Internal Client\", version: \"4.2.6\" }, os: { type: \"Linux\", name: \"Ubuntu\", architecture: \"x86_64\", version: \"18.04\" } }",
"2020-05-06T21:52:16.215+0000 I ACCESS [conn11] Successfully authenticated as principal admin on admin from client 127.0.0.1:56404"
],
"ok" : 1
}
> db.adminCommand( { getLog: "global" } )
I followed this guide when creating my certificate. I initially used the certificate created from here but it didn't work. Using the server certificate did the trick.

MongoDB log file shows connection accepted & end connection constantly

I'm trying to install MongoDb server in Redhat 7 GCE
After starting Mongod process with replication, the mongolog shows an error log..
`2017-12-29T20:51:12.853+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38130 #53 (1 connection now open)
2017-12-29T20:51:42.861+0530 I NETWORK [conn53] end connection
10.142.0.2:38130 (0 connections now open)
2017-12-29T20:51:42.862+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38136 #54 (1 connection now open)
2017-12-29T20:52:12.868+0530 I NETWORK [conn54] end connection
10.142.0.2:38136 (0 connections now open)
2017-12-29T20:52:12.869+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38144 #55 (1 connection now open)
2017-12-29T20:52:42.877+0530 I NETWORK [conn55] end connection
10.142.0.2:38144 (0 connections now open)
2017-12-29T20:52:42.877+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38150 #56 (1 connection now open)
2017-12-29T20:53:12.883+0530 I NETWORK [conn56] end connection
10.142.0.2:38150 (0 connections now open)
2017-12-29T20:53:12.883+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38156 #57 (1 connection now open)
2017-12-29T20:53:42.891+0530 I NETWORK [conn57] end connection
10.142.0.2:38156 (0 connections now open)
2017-12-29T20:53:42.892+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38162 #58 (1 connection now open)
2017-12-29T20:54:12.900+0530 I NETWORK [conn58] end connection
10.142.0.2:38162 (0 connections now open)
2017-12-29T20:54:12.900+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38170 #59 (1 connection now open)
2017-12-29T20:54:42.908+0530 I NETWORK [conn59] end connection
10.142.0.2:38170 (0 connections now open)
2017-12-29T20:54:42.908+0530 I NETWORK [initandlisten] connection accepted
from 10.142.0.2:38174 #60 (1 connection now open)
2017-12-29T20:55:12.917+0530 I NETWORK [conn60] end connection
10.142.0.2:38174 (0 connections now open)
`
I can connect from the redhat shell as
mongo --port 34672
but when i try to connect from an external ip it fails.
i was not able to find the reason for this error after checking all the error logs and searching in the web.
These log entries to not indicate an error. It is simply reporting connections. As for the reason for the connections, there could be several:
If you have an application using MongoDB, these connections are likely coming from that application.
If you have monitoring such as Stackdriver Monitoring installed, these could be connections from the monitoring to fetch statistics from MongoDB.
If you are using a cluster of MongoDB servers, this could be connections or health-checking between them.
I think (2) or (3) are especially likely, given that they are coming from internal IP addresses are are spaced exactly 30 seconds apart.
I believe your issue connecting externally is unrelated to these messages. If that is what you are really concerned about, I suggest you open a new question about that.

stuck of start mongoDB

2017-03-01T00:51:32.863-0500 I CONTROL [initandlisten]
2017-03-01T00:51:33.271-0500 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/mongo/data/diagnostic.data'
2017-03-01T00:51:33.284-0500 I NETWORK [thread1] waiting for connections on port 27017
2017-03-01T00:51:33.391-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50501 #1 (1 connection now open)
2017-03-01T00:51:33.394-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50502 #2 (2 connections now open)
2017-03-01T00:51:33.399-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50503 #3 (3 connections now open)
2017-03-01T00:51:33.401-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50504 #4 (4 connections now open)
2017-03-01T00:51:33.406-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50505 #5 (5 connections now open)
2017-03-01T00:51:33.418-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50506 #6 (6 connections now open)
When I start the mongoDB, the command line pop up these things, how could I fix it? I have tried delete the data folder...

MongoDB IntelliJ plugin failed with auth

I'm trying to connect to my mongo instance wich I ran as mongod --auth after configuring
use admin
db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
The configuration on Mongo-IntelliJ plugin looks like this:
The result is that the connection is refused.
Here is (some of) the output of mongod:
2016-10-26T08:40:09.218+0300 I NETWORK [conn45] end connection 127.0.0.1:59014 (0 connections now open)
2016-10-26T08:40:09.718+0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:59015 #46 (1 connection now open)
2016-10-26T08:40:09.721+0300 I NETWORK [conn46] end connection 127.0.0.1:59015 (0 connections now open)
2016-10-26T08:40:10.221+0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:59016 #47 (1 connection now open)
2016-10-26T08:40:10.224+0300 I NETWORK [conn47] end connection 127.0.0.1:59016 (0 connections now open)
2016-10-26T08:40:10.725+0300 I NETWORK [initandlisten] connection accepted from 127.0.0.1:59017 #48 (1 connection now open)
2016-10-26T08:40:10.728+0300 I NETWORK [conn48] end connection 127.0.0.1:59017 (0 connections now open)
I tried various combinations with the auth mechanism, but with the same results.
Is there something wrong in my configuration or in the plugin?

Strange MongoError (with ReactiveMongo) when Play reloads application

Very often, when Play reloads the application after a code change, I receive the following error:
MongoError['The node set can not be reached! Please check your network
connectivity.']
The MongoDB log looks like this:
2016-09-06T18:51:22.609+0200 I NETWORK [initandlisten] waiting for connections on port 27017
2016-09-06T18:53:49.916+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60559 #1 (1 connection now open)
2016-09-06T18:53:51.185+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60561 #2 (2 connections now open)
2016-09-06T18:53:51.196+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60562 #3 (3 connections now open)
2016-09-06T18:53:51.206+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60563 #4 (4 connections now open)
2016-09-06T18:53:51.217+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60564 #5 (5 connections now open)
2016-09-06T18:53:51.227+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60565 #6 (6 connections now open)
2016-09-06T18:53:51.237+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60566 #7 (7 connections now open)
2016-09-06T18:53:51.248+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60567 #8 (8 connections now open)
2016-09-06T18:53:51.258+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60568 #9 (9 connections now open)
2016-09-06T18:53:51.269+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60569 #10 (10 connections now open)
2016-09-06T18:53:59.533+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60577 #11 (11 connections now open)
2016-09-06T18:53:59.546+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60578 #12 (12 connections now open)
2016-09-06T18:53:59.557+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60579 #13 (13 connections now open)
2016-09-06T18:53:59.568+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60580 #14 (14 connections now open)
2016-09-06T18:53:59.579+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60581 #15 (15 connections now open)
2016-09-06T18:53:59.589+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60582 #16 (16 connections now open)
2016-09-06T18:53:59.600+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60583 #17 (17 connections now open)
2016-09-06T18:53:59.610+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60584 #18 (18 connections now open)
2016-09-06T18:53:59.620+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60585 #19 (19 connections now open)
2016-09-06T19:37:21.594+0200 I NETWORK [conn11] end connection 127.0.0.1:60577 (18 connections now open)
2016-09-06T19:37:21.596+0200 I NETWORK [conn1] end connection 127.0.0.1:60559 (17 connections now open)
2016-09-06T19:37:21.597+0200 I NETWORK [conn15] end connection 127.0.0.1:60581 (16 connections now open)
2016-09-06T19:37:21.597+0200 I NETWORK [conn13] end connection 127.0.0.1:60579 (15 connections now open)
2016-09-06T19:37:21.597+0200 I NETWORK [conn16] end connection 127.0.0.1:60582 (14 connections now open)
2016-09-06T19:37:21.598+0200 I NETWORK [conn12] end connection 127.0.0.1:60578 (13 connections now open)
2016-09-06T19:37:21.598+0200 I NETWORK [conn19] end connection 127.0.0.1:60585 (13 connections now open)
2016-09-06T19:37:21.599+0200 I NETWORK [conn17] end connection 127.0.0.1:60583 (11 connections now open)
2016-09-06T19:37:21.599+0200 I NETWORK [conn14] end connection 127.0.0.1:60580 (11 connections now open)
2016-09-06T19:37:21.600+0200 I NETWORK [conn18] end connection 127.0.0.1:60584 (9 connections now open)
2016-09-06T19:37:21.607+0200 I NETWORK [conn5] end connection 127.0.0.1:60564 (9 connections now open)
2016-09-06T19:37:21.607+0200 I NETWORK [conn9] end connection 127.0.0.1:60568 (9 connections now open)
2016-09-06T19:37:21.608+0200 I NETWORK [conn6] end connection 127.0.0.1:60565 (9 connections now open)
2016-09-06T19:37:21.608+0200 I NETWORK [conn10] end connection 127.0.0.1:60569 (9 connections now open)
2016-09-06T19:37:21.609+0200 I NETWORK [conn2] end connection 127.0.0.1:60561 (9 connections now open)
2016-09-06T19:37:21.609+0200 I NETWORK [conn7] end connection 127.0.0.1:60566 (9 connections now open)
2016-09-06T19:37:21.610+0200 I NETWORK [conn3] end connection 127.0.0.1:60562 (9 connections now open)
2016-09-06T19:37:21.611+0200 I NETWORK [conn4] end connection 127.0.0.1:60563 (4 connections now open)
2016-09-06T19:37:21.612+0200 I NETWORK [conn8] end connection 127.0.0.1:60567 (0 connections now open)
2016-09-06T19:37:22.326+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62077 #20 (1 connection now open)
2016-09-06T19:37:22.333+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62078 #21 (2 connections now open)
2016-09-06T19:37:22.333+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62079 #22 (3 connections now open)
2016-09-06T19:37:22.343+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62080 #23 (4 connections now open)
2016-09-06T19:37:22.344+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62081 #24 (5 connections now open)
2016-09-06T19:37:22.344+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62082 #25 (6 connections now open)
2016-09-06T19:37:22.344+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62083 #26 (7 connections now open)
2016-09-06T19:37:22.344+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62084 #27 (8 connections now open)
2016-09-06T19:37:22.354+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62085 #28 (9 connections now open)
2016-09-06T19:37:22.355+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62086 #29 (10 connections now open)
2016-09-06T19:37:32.348+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62105 #30 (11 connections now open)
2016-09-06T19:37:32.359+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62106 #31 (12 connections now open)
2016-09-06T19:37:32.393+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62107 #32 (13 connections now open)
2016-09-06T19:37:32.399+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62108 #33 (14 connections now open)
2016-09-06T19:37:32.399+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62109 #34 (15 connections now open)
2016-09-06T19:37:32.399+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62110 #35 (16 connections now open)
2016-09-06T19:37:32.399+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62111 #36 (17 connections now open)
2016-09-06T19:37:32.401+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62112 #37 (18 connections now open)
2016-09-06T19:37:32.401+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:62113 #38 (19 connections now open)
Sometimes there's also this exception:
[warn] r.c.a.MongoDBSystem - The entire node set is unreachable, is there a network problem?
[warn] r.c.a.MongoDBSystem - The entire node set is unreachable, is there a network problem?
[error] r.api.Failover2 - Got an error, no more attempts to do. Completing with a failure...
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$reactivemongo$core$actors$MongoDBSystem$$pickChannel$4.apply(actors.scala:748)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$reactivemongo$core$actors$MongoDBSystem$$pickChannel$4.apply(actors.scala:748)
at scala.Option.getOrElse(Option.scala:121)
at reactivemongo.core.actors.MongoDBSystem$class.reactivemongo$core$actors$MongoDBSystem$$pickChannel(actors.scala:748)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$4.applyOrElse(actors.scala:340)
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
at akka.actor.Actor$class.aroundReceive(Actor.scala:482)
at reactivemongo.core.actors.LegacyDBSystem.aroundReceive(actors.scala:896)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
[error] r.api.Failover2 - Got an error, no more attempts to do. Completing with a failure...
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$reactivemongo$core$actors$MongoDBSystem$$pickChannel$4.apply(actors.scala:748)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$reactivemongo$core$actors$MongoDBSystem$$pickChannel$4.apply(actors.scala:748)
at scala.Option.getOrElse(Option.scala:121)
at reactivemongo.core.actors.MongoDBSystem$class.reactivemongo$core$actors$MongoDBSystem$$pickChannel(actors.scala:748)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$4.applyOrElse(actors.scala:340)
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
at akka.actor.Actor$class.aroundReceive(Actor.scala:482)
at reactivemongo.core.actors.LegacyDBSystem.aroundReceive(actors.scala:896)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
[error] r.api.Failover2 - Got an error, no more attempts to do. Completing with a failure...
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$reactivemongo$core$actors$MongoDBSystem$$pickChannel$4.apply(actors.scala:748)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$reactivemongo$core$actors$MongoDBSystem$$pickChannel$4.apply(actors.scala:748)
at scala.Option.getOrElse(Option.scala:121)
at reactivemongo.core.actors.MongoDBSystem$class.reactivemongo$core$actors$MongoDBSystem$$pickChannel(actors.scala:748)
at reactivemongo.core.actors.MongoDBSystem$$anonfun$4.applyOrElse(actors.scala:340)
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
at akka.actor.Actor$class.aroundReceive(Actor.scala:482)
at reactivemongo.core.actors.LegacyDBSystem.aroundReceive(actors.scala:896)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
When I completely kill the process and execute activator run again, everything works like before.
Here's how I use ReactiveMongo:
val collection: Future[JSONCollection] = reactiveMongoApi.database.map(_.collection[JSONCollection](collectionName))
Used versions:
MongoDB: v3.2.4
Scala: 2.11.8
Play 2.5
play2-reactivemongo: 0.11.13
reactivemongo-play-json: 0.11.14
As developing like this takes forever, I would appreciate any help to fix this issue! :-)
I faced this issue as well; every time I reloaded my Play application (including hot reloads), I received hundreds of connection errors. After trying a couple times, my application would run fine until the next reload. This only started happening after I upgraded from ReactiveMongo 0.x to 1.x. I've tried running MongoDB (versions 3.2 through 4.0) locally, as both a native install and in a Docker container.
I "solved" it by adding the following connection options:
MongoConnectionOptions(maxIdleTimeMS = 100000, heartbeatFrequencyMS = 100)
The full connection looks like this:
private val driver = new reactivemongo.api.AsyncDriver
val connection: Future[MongoConnection] = driver.connect(List("localhost"), MongoConnectionOptions(maxIdleTimeMS = 100000, heartbeatFrequencyMS = 100))
I don't know why these values seem to work, or whether they're optimal. And I probably wouldn't recommend running a heartbeat of 100ms in production. However, it's working for my development needs, so I figured I'd share.