سؤال

I have a Mongo server running on an Ubuntu box, and I am trying to connect to it with pymongo using the usual syntax:

from pymongo import Connection
c = Connection('db.example.com', 27017)

This works just fine on a recent-model Intel mac (OS 10.6). However, the same code on an older G5 tower (10.5) throws this error:

pymongo.errors.AutoReconnect: [Errno 54] Connection reset by peer

The mongo output on the server reports:

connection accepted from oldmac.example:57681 #3
bad recv() len: 973078528
end connection oldmac.example:57681

I know that I cannot run the mongodb server from the PPC Mac, but it seems odd that I wouldn't be able to connect to the remote database. Or is something else at fault?

هل كانت مفيدة؟

المحلول

Looks like Mike Dirolf already answered your question in the MongoDB Google Group. But for people experiencing the same issue and find themselves on this page, the solution from Mike Dirolf:

Are you using the C extension? (try pymongo.has_c()). I wouldn't think that the C extension would even build on PPC but if it did that is almost certainly the reason this isn't working. You can install w/o C with python setup.py install --no_ext and then I'd expect things to work.

-- Mike Dirolf

نصائح أخرى

I was able to solve this same issue by using MongoClient instead of the deprecated Connection.

From the Python driver for MongoDB page

Warning DEPRECATED: Connection is deprecated. Please use MongoClient instead.

For more information, see the new MongoClient documentation for Python.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top