Rethinkdb and python driver-unable to connect

2019-06-01 08:01发布

问题:

Im having a problem with connecting to my RethinkDB local host using my python driver. The directory structure is:

home/rethinkdb/drivers/python.

When Im inside this python directory I start the python shell. I type import rethinkdb as r r.connect('localhost', 28015).repl()

I get the error:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "rethinkdb/net.py", line 366, in connect
        return Connection(host, port, db, auth_key, timeout)
  File "rethinkdb/net.py", line 136, in __init__
    self.reconnect(noreply_wait=False)
  File "rethinkdb/net.py", line 157, in reconnect
    self._sock_sendall(struct.pack("<L", p.VersionDummy.Protocol.JSON))
  File "rethinkdb/net.py", line 219, in _sock_sendall
    return self.socket.sendall(data)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
**socket.error: [Errno 32] Broken pipe**

I have no idea why this occurs-Help appreciated!

回答1:

Try this to connect:

r.connect(host="localhost", port=28015).repl()

And make sure that the server and the driver has a matching version (at least the first two numbers).

rethinkdb --version
pip freeze | grep rethinkdb

If they don't, update the server/driver.