Skip to content

Instantly share code, notes, and snippets.

@alcaeus
Last active October 13, 2016 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alcaeus/018e8e647f1a44622017f7604fe0cfcd to your computer and use it in GitHub Desktop.
Save alcaeus/018e8e647f1a44622017f7604fe0cfcd to your computer and use it in GitHub Desktop.
Invalid command cursor on listCollections with a sharded cluster in MongoDB 3.2

Install mongo-orchestration and start a sharded cluster:

mongo-orchestration -b 127.0.0.1 -p 8889 --no-fork start
curl -XPUT http://localhost:8889/v1/sharded_clusters/myCluster --data @configurations/sharded_clusters/clean.json

Then, run the included PHP script:

$ php invalid-cursor-listCollections.php
PHP Fatal error:  Uncaught exception 'MongoCursorException' with message 'localhost:27017: the command cursor did not return a correctly structured response' in invalid-cursor-listCollections.php:7
Stack trace:
#0 invalid-cursor-listCollections.php(7): MongoDB->listCollections()
#1 {main}
  thrown in invalid-cursor-listCollections.php on line 7
<?php
$client = new MongoClient();
$client->dropDb('invalid-cursor-test');
$db = $client->selectDb('invalid-cursor-test');
$db->listCollections();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment