You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I attempt to open a connection to RabbitMQ using the stomp.WSConnection class, I receive an exception:
Traceback (most recent call last):
File "c:\git\dai\venv\lib\site-packages\stomp\transport.py", line 376, in __read
c = self.receive()
File "c:\git\dai\venv\lib\site-packages\stomp\adapter\ws.py", line 252, in receive
return self.socket.recv().encode()
AttributeError: 'bytes' object has no attribute 'encode'
which leads to a ConnectFailedException:
File "c:\git\dai\venv\lib\site-packages\stomp\connect.py", line 199, in connect
Protocol12.connect(self, *args, **kwargs)
File "c:\git\dai\venv\lib\site-packages\stomp\protocol.py", line 529, in connect
self.transport.wait_for_connection()
File "c:\git\dai\venv\lib\site-packages\stomp\transport.py", line 318, in wait_for_connection
raise exception.ConnectFailedException()
stomp.exception.ConnectFailedException
hi, that seems like a reasonable solution. There would need to be a configuration at the WSConnection constructor, default as tring, since by default RabbitMQ is configured as UTF-8
By default, the Web STOMP plugin will expect to handle messages encoded as UTF-8
Using stomp.py-8.1.0
The server I am connecting to is RabbitMQ with the
rabbitmq_web_stomp
plugin.The web stomp plugin is configured to send binary messages, as documented here: https://www.rabbitmq.com/web-stomp.html#content-encoding:
When I attempt to open a connection to RabbitMQ using the
stomp.WSConnection
class, I receive an exception:which leads to a
ConnectFailedException
:The problem seems to be that the
WSTransport.receive
method assumes that all websocket messages are strings, and tries to convert them back into bytes: https://github.com/jasonrbriggs/stomp.py/blob/dev/stomp/adapter/ws.py#L215I think it would be possible to fix this issue by calling the
recv_data
method, rather thanrecv
:If you agree, I would be happy to submit a PR.
The text was updated successfully, but these errors were encountered: