switch {
case desiredInterval == -1:
interval = -1
case desiredInterval == 0:
// do nothing (use default)
case desiredInterval >= 1000 &&
desiredInterval <= int(c.context.nsqd.options.MaxHeartbeatInterval/time.Millisecond):
interval = (time.Duration(desiredInterval) * time.Millisecond)
default:
return errors.New(fmt.Sprintf("heartbeat interval (%d) is invalid", desiredInterval))
}
Also, when I use 0 as the heartbeat_interval, the client library throws an AssertionError because it doesn't like the 0. And interestingly, if you set the heartbeat_interval to 1000 or higher, you get this error from the client lib:
ERROR:root:uncaught exception in data event
Traceback (most recent call last):
File "/<DELETED>/lib/python2.7/site-packages/nsq/async.py", line 183, in _read_body
self.trigger('data', conn=self, data=data)
File "/<DELETED>/lib/python2.7/site-packages/nsq/evented_mixin.py", line 59, in trigger
ev(*args, **kwargs)
File "/<DELETED>/lib/python2.7/site-packages/nsq/async.py", line 320, in _on_data
self.trigger('response', conn=self, data=data)
File "/<DELETED>/lib/python2.7/site-packages/nsq/evented_mixin.py", line 59, in trigger
ev(*args, **kwargs)
File "/<DELETED>/lib/python2.7/site-packages/nsq/async.py", line 279, in _on_identify_response
self.trigger('identify_response', conn=self, data=data)
File "/<DELETED>/lib/python2.7/site-packages/nsq/evented_mixin.py", line 59, in trigger
ev(*args, **kwargs)
File "/<DELETED>/lib/python2.7/site-packages/nsq/client.py", line 16, in _on_connection_identify_response
if self.tls_v1 and not data.get('tls_v1'):
AttributeError: 'Reader' object has no attribute 'tls_v1'
——————————————
My setup and output looks like so:
———— test_client.py ————
import nsq
def process_message(message):
print message
r = nsq.Reader(topic="test", channel="test_channel1", message_handler=process_message,
lookupd_http_addresses=['http://127.0.0.1:4161'])
nsq.run()
——————————————
———— test_client.py output ————
ERROR:root:[monkeybrain:4150:test:test_channel1] ERROR: Error('E_BAD_BODY IDENTIFY heartbeat interval (30) is invalid',)
ERROR:tornado.application:Exception in callback <functools.partial object at 0x10a46daa0>
Traceback (most recent call last):
File "/<DELETED>/lib/python2.7/site-packages/tornado/ioloop.py", line 477, in _run_callback
callback()
File "/<DELETED>/lib/python2.7/site-packages/tornado/stack_context.py", line 331, in wrapped
raise_exc_info(exc)
File "/<DELETED>/lib/python2.7/site-packages/tornado/stack_context.py", line 302, in wrapped
ret = fn(*args, **kwargs)
File "/<DELETED>/lib/python2.7/site-packages/nsq/async.py", line 164, in _start_read
self.stream.read_bytes(4, self._read_size)
File "/<DELETED>/lib/python2.7/site-packages/tornado/iostream.py", line 177, in read_bytes
self._try_inline_read()
File "/<DELETED>/lib/python2.7/site-packages/tornado/iostream.py", line 431, in _try_inline_read
self._check_closed()
File "/<DELETED>/lib/python2.7/site-packages/tornado/iostream.py", line 593, in _check_closed
raise StreamClosedError("Stream is closed")
StreamClosedError: Stream is closed
WARNING:root:[monkeybrain:4150:test:test_channel1] connection closed
——————————————————
———— nsqd console ————-
2014/02/15 19:22:28 TCP: new client(192.168.1.46:65162)
2014/02/15 19:22:28 CLIENT(192.168.1.46:65162): desired protocol magic ' V2'
2014/02/15 19:22:28 ERROR: [192.168.1.46:65162] - E_BAD_BODY IDENTIFY heartbeat interval (30) is invalid - heartbeat interval (30) is invalid
2014/02/15 19:22:28 PROTOCOL(V2): [192.168.1.46:65162] exiting ioloop
2014/02/15 19:22:28 PROTOCOL(V2): [192.168.1.46:65162] exiting messagePump
———————————————