Timeout issues with Riak Python Client with protocol buffers

I see the strange but consistent behavior of the Python Riak client when connecting to my riak AWS cluster using protocol buffers. This short snippet of python code causes an error:

import time
import riak

client = riak.RiakClient(
            host='address_to_my_cluster_goes_here',
            http_port=8098,
            pb_port=8087,
            protocol='pbc'
         )

result = client.ping()

# Do something else for a while, > 60 seconds
time.sleep(61)

result = client.ping()

The last ping always throws an exception with the following trace:

Traceback (most recent call last):
  File "main_causing_exception.py", line 16, in <module>
    result = client.ping()
  File "C:\temp\venv\lib\site-packages\riak\client\transport.py", line 127, in wrapper
    return self._with_retries(pool, thunk)
  File "C:\temp\venv\lib\site-packages\riak\client\transport.py", line 69, in _with_retries
    return fn(transport)
  File "C:\temp\venv\lib\site-packages\riak\client\transport.py", line 125, in thunk
    return fn(self, transport, *args, **kwargs)
  File "C:\temp\venv\lib\site-packages\riak\client\operations.py", line 92, in ping
    return transport.ping()
  File "C:\temp\venv\lib\site-packages\riak\transports\pbc\transport.py", line 95, in ping
    msg_code, msg = self._request(MSG_CODE_PING_REQ)
  File "C:\temp\venv\lib\site-packages\riak\transports\pbc\connection.py", line 43, in _request
    return self._recv_msg(expect)
  File "C:\temp\venv\lib\site-packages\riak\transports\pbc\connection.py", line 50, in _recv_msg
    self._recv_pkt()
  File "C:\temp\venv\lib\site-packages\riak\transports\pbc\connection.py", line 71, in _recv_pkt
    % len(nmsglen))
  riak.RiakError: 'Socket returned short packet length 0 - expected 4'

If I do it client.ping()every 30 seconds or so, an error does not occur, indicating that this is some kind of socket preservation problem that I see, but it does not seem like a reasonably robust solution for a production environment.

The error only occurs when using the protocol parameter pbc, and I have never seen it when using the configured httpRiak Python client.

Python 2.7.5 Win7-64 ( Ubuntu) :

  • protobuf (2.4.1)
  • riak (2.0.1)
  • riak-pb (1.4.1.1)

, ? Python Riak Client ?

+4

All Articles