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

Getting peer address with self._protocol.remote_address in WebSocketsWriter #194

Merged
merged 1 commit into from Jan 25, 2020
Merged

Conversation

ntoonio
Copy link
Contributor

@ntoonio ntoonio commented Nov 28, 2019

I was getting this error when trying to connect via websockets, but not TCP.

.../venv/lib/python3.7/site-packages/websockets/server.py:193 Error in connection handler Traceback (most recent call last):
  File ".../venv/lib/python3.7/site-packages/websockets/server.py", line 191, in handler
    await self.ws_handler(self, path)
  File ".../venv/lib/python3.7/site-packages/hbmqtt/broker.py", line 340, in ws_connected
    yield from self.client_connected(listener_name, WebSocketsReader(websocket), WebSocketsWriter(websocket))
  File ".../venv/lib/python3.7/site-packages/hbmqtt/broker.py", line 354, in client_connected
    remote_address, remote_port = writer.get_peer_info()
  File ".../venv/lib/python3.7/site-packages/hbmqtt/adapters.py", line 124, in get_peer_info
    extra_info = self._protocol.writer.get_extra_info('peername')
AttributeError: 'WebSocketServerProtocol' object has no attribute 'writer'

This was fixed by changing self._protocol.writer.get_extra_info('peername') to self._protocol.remote_address. I guess this bug snuck in there when someone copied the code from the TCP counterpart.

@coveralls
Copy link

Coverage Status

Coverage remained the same at ?% when pulling b0505ff on ntoonio:master into fc462d1 on beerfactory:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at ?% when pulling b0505ff on ntoonio:master into fc462d1 on beerfactory:master.

@vksbhandary
Copy link

I am facing this problem.
Can anyone merge the pull request?

Thank you so much.

@ntoonio
Copy link
Contributor Author

ntoonio commented Jan 8, 2020

@vksbhandary FOR NOW you can use $ pip install https://github.com/ntoonio/hbmqtt/archive/master.zip. I can't swear that this will be available in the future. If this doesn't get merged you can fork that repo and then download from your fork :)

@njouanin njouanin merged commit 87ac03b into njouanin:master Jan 25, 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

Successfully merging this pull request may close these issues.

None yet

4 participants