MongoDB Document size too large

mongodb

I'm having trouble with my MongoDB Replica Set. I'm connecting to the server and using the database fine from two servers but on another server I'm getting the following error:

bson.errors.InvalidDocument:
    BSON document too large (2119 bytes) -
    the connected server supports BSON document sizes up to 0 bytes.

I have no idea where to begin on this, my MongoDB Server version is 2.4.10, the code on each server is the same with some configuration file differences. The DB Server is on AWS as are the two working servers. The server that is not working is on a Digital Ocean server.

I have allowed the Digital Ocean server access to the DB server with AWS Security Groups and it seems to be connecting fine.

Also, I am able to access and update the database from my local machine using the command line and RoboMongo.

Best Answer

The replica set was setup with the internal AWS addresses. So when python connected with MongoReplicaSetClient and the server sent back the addresses it couldn't find the other members of the replica set.

You can update the replica set using rs.conf() to get the config and then rs.reconfig() to set your new configuration.

Or, as I did, add the internal AWS address to the server hosts file, which I was able to do because it was not the internal AWS IP that was used.