Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS certification failed #25

Open
bizky opened this issue Jun 9, 2019 · 1 comment
Open

TLS certification failed #25

bizky opened this issue Jun 9, 2019 · 1 comment

Comments

@bizky
Copy link

bizky commented Jun 9, 2019

When I use the TLS cerification of gnsq, the code raised a exception.
The Traceback of the exception is

Traceback (most recent call last):
  File "test.py", line 10, in <module>
    producer.start()
  File "/usr/local/lib/python3.5/dist-packages/gnsq/producer.py", line 112, in start
    self.connect_to_nsqd(address, int(port))
  File "/usr/local/lib/python3.5/dist-packages/gnsq/producer.py", line 154, in connect_to_nsqd
    conn.identify()
  File "/usr/local/lib/python3.5/dist-packages/gnsq/nsqd.py", line 381, in identify
    self.upgrade_to_tls()
  File "/usr/local/lib/python3.5/dist-packages/gnsq/nsqd.py", line 319, in upgrade_to_tls
    self.check_ok()
  File "/usr/local/lib/python3.5/dist-packages/gnsq/nsqd.py", line 307, in check_ok
    frame, data = self.read_response()
  File "/usr/local/lib/python3.5/dist-packages/gnsq/nsqd.py", line 257, in read_response
    processed_data = frame_handler(data)
  File "/usr/local/lib/python3.5/dist-packages/gnsq/nsqd.py", line 265, in handle_response
    self.on_response.send(self, response=data)
  File "/usr/local/lib/python3.5/dist-packages/blinker/base.py", line 267, in send
    for receiver in self.receivers_for(sender)]
  File "/usr/local/lib/python3.5/dist-packages/blinker/base.py", line 267, in <listcomp>
    for receiver in self.receivers_for(sender)]
  File "/usr/local/lib/python3.5/dist-packages/gnsq/producer.py", line 217, in handle_response
    result = self._response_queues[conn].popleft()

It seems that the self._response_queues of conn is missing, because the value of self._response_queues is {} when running at the last exception code.


The NSQD(v1.1.0) is run by the following command:

./nsqd --lookupd-tcp-address=127.0.0.1:4160 -tls-cert=./certs/server.pem -tls-key=./certs/server.key -tls-root-ca-file=./certs/ca.pem -tls-required=true

where, the certs folder is generated by the official command of nsq.


The Python code to connect to the nsqd is shown as following:

from gnsq import Producer

tls_options = {
    'keyfile': "./certs/server.key",
    'certfile': "./certs/server.pem",
}

producer = Producer('127.0.0.1:4150',tls_v1 = True, tls_options = tls_options)
producer.start()
producer.publish('topic', b'hello world')

@herberthamaral
Copy link

I'm having the same problem. I managed to fix it (temporarily) by changing the handle_response in gnsq/producer.py from this:

    def handle_response(self, conn, response):
        self.logger.debug('[%s] response: %s', conn, response)

        if response == nsq.OK:
            result = self._response_queues[conn].popleft()
            result.set(response)

        self.on_response.send(self, response=response)

To this:

    def handle_response(self, conn, response):
        self.logger.debug('[%s] response: %s', conn, response)

        if response == nsq.OK:
            if conn in self._response_queues:
                result = self._response_queues[conn].popleft()
                result.set(response)

        self.on_response.send(self, response=response)

herberthamaral added a commit to herberthamaral/gnsq that referenced this issue Sep 5, 2019
herberthamaral added a commit to herberthamaral/gnsq that referenced this issue Sep 5, 2019
bgeisberger pushed a commit to bgeisberger/gnsq that referenced this issue Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants