Repository: dpkp/kafka-python

Issue #520: kafka-python does not work on Windows
Created: 2016-01-26T15:54:27Z
OS: Windows 8
kafka-python version: 0.97.0-dev
Trying to run:
producer = KafkaProducer(bootstrap_servers=[KAFKA_ADDRESS])

Getting an error:
2016-01-26 18:10:08,252 kafka.producer.kafka DEBUG    Starting the Kafka producer
2016-01-26 18:10:08,252 kafka.client DEBUG    Attempting to bootstrap via node at 10.250.181.19:9092
2016-01-26 18:10:08,253 kafka.conn   ERROR    Connect attempt to <BrokerConnection host=10.250.181.19 port=9092> returned error 10035. Disconnecting.
2016-01-26 18:10:08,253 kafka.client ERROR    Unable to bootstrap from [('10.250.181.19', 9092)]
2016-01-26 18:10:08,253 kafka.client DEBUG    No connected nodes found. Trying disconnected nodes.
2016-01-26 18:10:08,253 kafka.client DEBUG    No luck. Trying all broker metadata
2016-01-26 18:10:08,253 kafka.client ERROR    No nodes found in metadata -- retrying bootstrap
2016-01-26 18:10:08,254 kafka.client DEBUG    Sleeping 0.0980 before bootstrapping again
2016-01-26 18:10:08,352 kafka.client DEBUG    Attempting to bootstrap via node at 10.250.181.19:9092
2016-01-26 18:10:08,352 kafka.conn   ERROR    Connect attempt to <BrokerConnection host=10.250.181.19 port=9092> returned error 10035. Disconnecting.
2016-01-26 18:10:08,352 kafka.client ERROR    Unable to bootstrap from [('10.250.181.19', 9092)]
Traceback (most recent call last):
  File "sample.py", line 5, in <module>
   producer = KafkaProducer(bootstrap_servers=[KAFKA_ADDRESS])
  File "C:\Program Files\Python35\lib\site-packages\kafka_python-0.97.0.dev0-py3.5.egg\kafka\producer\kafka.py", line 245, in __init__
  File "C:\Program Files\Python35\lib\site-packages\kafka_python-0.97.0.dev0-py3.5.egg\kafka\client_async.py", line 607, in check_version
  File "C:\Program Files\Python35\lib\site-packages\kafka_python-0.97.0.dev0-py3.5.egg\kafka\client_async.py", line 575, in connect
kafka.common.NodeNotReadyError: None

Found this code in the conn.py:
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF,
                                  self.config['receive_buffer_bytes'])
            self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF,
                                  self.config['send_buffer_bytes'])
            self._sock.setblocking(False)
            ret = self._sock.connect_ex((self.host, self.port))
            self.last_attempt = time.time()

            if not ret or ret is errno.EISCONN:
                self.state = ConnectionStates.CONNECTED
            elif ret in (errno.EINPROGRESS, errno.EALREADY):
                self.state = ConnectionStates.CONNECTING
            else:
                log.error('Connect attempt to %s returned error %s.'
                          ' Disconnecting.', self, ret)
                self.close()
                self.last_failure = time.time()

On my machine, ret contains EWOULDBLOCK, and this seems to be normal. Do you need to handle EWOULDBLOCK in this case or my machine is merely glitchy and should not return EWOULDBLOCK on socket opening?

Duplicate issue #586: Help: Using kafka-python on Windows 
Created: 2016-03-13T23:12:15Z
Does this work on windows?  I can't seem to get a connection, though other libraries (c# for example) work fine.
Here is the output on windows 10 Python 2.7
Attempting to bootstrap via node at <connectioninfo>
No connection nodes found.  Trying disconnected nodes.
No luck.  Trying all broker metadata
No nodes found in metadata -- retrying bootstrap
Sleeping 0.0990 before bootstrapping again
Attempting to bootstrap via node at <connectioninfo>
Unable to bootstrap from <connectioninfo>
Traceback (most recent call last):
  File "C:/Users/kgobe/PycharmProjects/KafkaTest/test.py", line 15, in <module>
    producer = KafkaProducer(bootstrap_servers='<connectioninfo>')
  File "C:\Users\kgobe\Testing\lib\site-packages\kafka\producer\kafka.py", line 248, in __init__
    self.config['api_version'] = client.check_version()
  File "C:\Users\kgobe\Testing\lib\site-packages\kafka\client_async.py", line 635, in check_version
    connect(node_id)
  File "C:\Users\kgobe\Testing\lib\site-packages\kafka\client_async.py", line 598, in connect
    raise Errors.NodeNotReadyError(node_id)
kafka.common.NodeNotReadyError: None

Whereas the output of the same code running ubuntu 14.04 server is this
Attempting to bootstrap via node at <connectioninfo>
No connected nodes found. Trying disconnected nodes.
No luck. Trying all broker metadata
Initiating connection at node 0 at <full host name>
Node 0 connection state is <connected>
Broker is not v0.9 -- it did not recognize ListGroupsRequest
Node 0 connection state is <connected>
Broker version identified as 0.8.2

Apparently my broker is 0.8.2, if I upgrade to 0.9 will it work on windows?

Closing comment (2016-03-15T00:58:25Z): closing as duplicate of #520