Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1054

Error "Cannot read property 'wireProtocolHandler' of null" when server is not ready

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.29
    • Component/s: None
    • Labels:
    • Environment:
      Rs: PRIMARY + 2 x SECONDAY
      Node: 4.8.3
      mongodb: 2.2.29,branch `fix-url-parse-options`

      I have the following setup

      {
        "mongo1": {
          "type": "PRIMARY",
          "tags": {
            "continent": "america"
          }
        },
        "mongo2": {
          "type": "SECONDARY",
          "tag": {
            "continent": "europe"
          }
        },
        "mongo3": {
          "type": "SECONDARY",
          "tag": {
            "continent": "africa"
          }
        }
      }
      

      and mongodb client is located in europe and trying to connect to africa with the following options

      connectionUrl = 'mongodb://mongo1:27017/data?replicaSet=rs'
      {
          replicaSet: 'rs',
          connectWithNoPrimary: true,
          readPreference: new ReadPreference('secondary', [
              {
                  'continent': 'africa'
              }
          ])
      };
      

      The client tries to connect, MongoClient.connect success handler is called and the client tries a find and recievies an error(because mongo3 is located in africa and there is a big latency between africa and europe):

      TypeError: Cannot read property 'wireProtocolHandler' of null
          at nextFunction (/wk/bit/libs/perf/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:568:31)
          at Cursor.next [as _next] (/wk/bit/libs/perf/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:692:3)
          at nextObject (/wk/bit/libs/perf/node_modules/mongodb/lib/cursor.js:679:8)
          at Cursor.next (/wk/bit/libs/perf/node_modules/mongodb/lib/cursor.js:269:12)
          at findOne (/wk/bit/libs/perf/node_modules/mongodb/lib/collection.js:1415:10)
          at Collection.findOne (/wk/bit/libs/perf/node_modules/mongodb/lib/collection.js:1401:44)
          at Context.<anonymous> (/wk/bit/libs/perf/test/test.js:58:38)
          at callFnAsync (/usr/local/lib/node_modules/mocha/lib/runnable.js:368:21)
          at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:318:7)
          at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:444:10)
          at /usr/local/lib/node_modules/mocha/lib/runner.js:550:12
          at next (/usr/local/lib/node_modules/mocha/lib/runner.js:361:14)
          at /usr/local/lib/node_modules/mocha/lib/runner.js:371:7
          at next (/usr/local/lib/node_modules/mocha/lib/runner.js:295:14)
          at Immediate._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:339:5)
          at processImmediate [as _immediateCallback] (timers.js:396:17)
      
      

      If I remove connectWithNoPrimary: true from options OR I add mongo3 server to connectionUrl:'mongodb://mongo1:27017,mongo3:27017/data?replicaSet=rs' everything will work.

      What is the right behaviour?

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            mciocan Marius Ciocan
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: