9

On our Sitecore 8 production instance, we are getting the below error messages. This client site we have recently inherited from another partner and on preliminary investigation from our end, we see they have implemented replica sets for MongoDB

<add name="analytics" connectionString="mongodb://{IP}:27017,{IP}:27018/sitecore_analytics?replicaset=SiteCoreDMS" />

Which looks correct. These are the errors in Sitecore logs:

7056 04:22:01 ERROR Cannot create tracker.
Exception: System.IO.IOException
Message: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Source: System
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at MongoDB.Bson.IO.ByteBufferFactory.LoadFrom(Stream stream)
   at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationOptions serializationOptions)
   at MongoDB.Driver.Operations.QueryOperation`1.GetFirstBatch(IConnectionProvider connectionProvider)
   at MongoDB.Driver.Operations.QueryOperation`1.<Execute>d__0.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbCollection.<>c__DisplayClass29`1.<FindOneAs>b__28()
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbCollection.Execute(Action action, ExceptionBehavior exceptionBehavior)
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbCollection.FindOneAs[TDocument](IMongoQuery query, ExceptionBehavior exceptionBehavior)
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbContactStorage.LoadContactIdentifier(ID id)
   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.TryLoadContact(ID id, IContactFactory factory, LeaseOwner leaseOwner, TimeSpan leaseDuration)
   at Sitecore.Analytics.Data.ContactRepository.TryLoadContact(Guid id, LeaseOwner leaseOwner, TimeSpan leaseDuration)
   at Sitecore.Analytics.Tracking.ContactManager.TryLoadContact(Guid contactId, Int32 lockDurationMinutes)
   at Sitecore.Analytics.Pipelines.EnsureSessionContext.LoadContact.Process(InitializeTrackerArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Analytics.DefaultTracker.EnsureSessionContext()
   at Sitecore.Analytics.Pipelines.CreateTracker.GetTracker.Process(CreateTrackerArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Analytics.Tracker.Initialize()

Nested Exception

Exception: System.Net.Sockets.SocketException
Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Source: System
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)


7056 04:22:01 ERROR Cannot start analytics.
Exception: System.InvalidOperationException
Message: Tracker.Current is not initialized
Source: Sitecore.Analytics
   at Sitecore.Analytics.Pipelines.StartAnalytics.StartTracking.Process(PipelineArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Analytics.Pipelines.HttpRequest.StartAnalytics.Process(RenderLayoutArgs args)

--------------------------------------------

ERROR Exception when executing agent aggregation/automationRangeManager
Exception: System.IO.IOException
Message: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Source: System
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at MongoDB.Bson.IO.ByteBufferFactory.LoadFrom(Stream stream)
   at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationOptions serializationOptions)
   at MongoDB.Driver.Operations.QueryOperation`1.GetFirstBatch(IConnectionProvider connectionProvider)
   at MongoDB.Driver.Operations.QueryOperation`1.<Execute>d__0.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Sitecore.Analytics.Automation.Data.MongoDbAutomationProvider.GetEarliestAutomationTransitionTimestamp()
   at Sitecore.Analytics.Automation.Aggregation.Data.Processing.RangeManagerAgent.Execute()
   at Sitecore.Analytics.Core.BackgroundService.Run()

Nested Exception

Exception: System.Net.Sockets.SocketException
Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Source: System
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

Attaching output of rs.status()

SiteCoreDMS:SECONDARY> rs.status()
{
    "set" : "SiteCoreDMS",
    "date" : ISODate("2016-10-12T06:49:33Z"),
    "myState" : 2,
    "syncingTo" : "42.159.226.69:27017",
    "members" : [
            {
                    "_id" : 0,
                    "name" : "42.159.225.222:27017",
                    "health" : 1,
                    "state" : 2,
                    "stateStr" : "SECONDARY",
                    "uptime" : 2474004,
                    "optime" : Timestamp(1476254930, 1),
                    "optimeDate" : ISODate("2016-10-12T06:48:50Z"),
                    "lastHeartbeat" : ISODate("2016-10-12T06:49:32Z"),
                    "lastHeartbeatRecv" : ISODate("2016-10-12T06:49:31Z"),
                    "pingMs" : 0,
                    "syncingTo" : "42.159.226.69:27017"
            },
            {
                    "_id" : 1,
                    "name" : "42.159.225.222:27018",
                    "health" : 1,
                    "state" : 2,
                    "stateStr" : "SECONDARY",
                    "uptime" : 2474006,
                    "optime" : Timestamp(1476254930, 1),
                    "optimeDate" : ISODate("2016-10-12T06:48:50Z"),
                    "self" : true
            },
            {
                    "_id" : 2,
                    "name" : "42.159.226.69:27017",
                    "health" : 1,
                    "state" : 1,
                    "stateStr" : "PRIMARY",
                    "uptime" : 2474002,
                    "optime" : Timestamp(1476254930, 1),
                    "optimeDate" : ISODate("2016-10-12T06:48:50Z"),
                    "lastHeartbeat" : ISODate("2016-10-12T06:49:32Z"),
                    "lastHeartbeatRecv" : ISODate("2016-10-12T06:49:33Z"),
                    "pingMs" : 2,
                    "electionTime" : Timestamp(1474819533, 1),
                    "electionDate" : ISODate("2016-09-25T16:05:33Z")
            }
    ],
    "ok" : 1
}
SiteCoreDMS:SECONDARY>
10
  • Please log into MongoDB manually (using the mongo client) and get replica set configuration using the command rs.conf(). Attach the output here. Oct 12, 2016 at 5:45
  • SiteCoreDMS:SECONDARY> rs.conf() { "_id" : "SiteCoreDMS", "version" : 10, "members" : [ { "_id" : 0, "host" : "42.159.225.222:27017" }, { "_id" : 1, "host" : "42.159.225.222:27018" }, { "_id" : 2, "host" : "42.159.226.69:27017"
    – Abhay Dhar
    Oct 12, 2016 at 5:59
  • } ], "settings" : { "getLastErrorDefaults" : { "w" : 1, "wtimeout" : 0 } } }
    – Abhay Dhar
    Oct 12, 2016 at 5:59
  • Also, could you please edit your question and attach the output of rs.status()? Oct 12, 2016 at 6:15
  • 1
    Of course you cannot see anything there—your application cannot access MongoDB. Please use mongo.exe on the server where your Sitecore application is running and try connecting from that server directly to the replica set: mongo --host SiteCoreDMS/42.159.226.69:27017,42.159.225.222:27017,42.159.225.222:27018 sitecore_analytics. Oct 12, 2016 at 7:14

3 Answers 3

4

According to the output of rs.conf(), you currently have three replica set members: two of them hosted on 42.159.225.222, and another one on 42.159.226.69.

You need to make sure that the Sitecore application has direct access to both of these IP addresses via the ports specified. Even though you only have 42.159.225.222 in your connection string, the MongoDB driver may attempt to connect to any server available in the replica set.

3
  • for seconday 226.69 port 27018 is blocked ..
    – Abhay Dhar
    Oct 12, 2016 at 7:05
  • You don't have a secondary on 226.69:27018. Oct 12, 2016 at 7:08
  • I have checked all the ip and ports .. using telnet . Sitecore is able to communicate with Mongo perfectly
    – Abhay Dhar
    Oct 12, 2016 at 7:12
3

Your connectionstring shows two different ports for each server, is that correct? Because Mongo recommends keeps on the same port for a Replica Set environment

In a production, deploy each member of the replica set to its own machine and if possible bind to the standard MongoDB port of 27017

Also, are you able to connect from one mongo to another? Please see the line below

From Server1

mongo --host m2.example.net --port 27017

From Server2

mongo --host m1.example.net --port 27017

Please let us know if your results

1

First of all, could you check if your mongo processes are running?

A good thing to do is check wether your resultset is working properly. Try to run the following command on the commandline and check the output:

mongo --eval "db.isMaster()"

You should see some output like thus:

{
    "hosts" : [
            "host1:27017",
            "host2:27017",
            "host3:27017"
    ],
    "setName" : "DSM",
    "setVersion" : 3,
    "ismaster" : true,
    "secondary" : false,
    "primary" : "host1",
    "me" : "host1",
    "electionId" : ObjectId("7fffffff00000000000001ff"),
    "maxBsonObjectSize" : 16777216,
    "maxMessageSizeBytes" : 48000000,
    "maxWriteBatchSize" : 1000,
    "localTime" : ISODate("2016-10-13T14:42:02.398Z"),
    "maxWireVersion" : 4,
    "minWireVersion" : 0,
    "ok" : 1 }

When your output looks like that, you can be sure your resultset is working properly.

I that case it could be a simple fix by not writing your connection string with:

?replicaset=SiteCoreDMS

but instead:

?replicaSet=SiteCoreDMS

reviewing the Sitecore connectionstring documentation involving replicasets, i can see the capital S in every string.

Let me know if this worked out for you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.