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

coilmq sends CONNECTED twice when handling STOMP 1.0 CONNECT #32

Open
ejd opened this issue Oct 6, 2021 · 0 comments
Open

coilmq sends CONNECTED twice when handling STOMP 1.0 CONNECT #32

ejd opened this issue Oct 6, 2021 · 0 comments

Comments

@ejd
Copy link
Collaborator

ejd commented Oct 6, 2021

When coilmq handles a STOMP 1.0 CONNECT frame, it sends two CONNECTED frames to the client.

The first CONNECTED is sent because STOMP11._negotiate_protocol() instantiates the class that handles the other protocol version and calls the instances connect method (line 326 below):

def _negotiate_protocol(self, frame, response):
client_versions = frame.headers.get('accept-version', '1.0')
if not client_versions:
raise ProtocolError('No version specified')
common = set(client_versions.split(',')) & self.SUPPORTED_VERSIONS
if not common:
versions = ','.join(self.SUPPORTED_VERSIONS)
self.engine.connection.send_frame(Frame(
frames.ERROR,
headers={'version': versions, 'content-type': frames.TEXT_PLAIN},
body='Supported protocol versions are {0}'.format(versions)
))
else:
response.headers['version'] = max(common)
protocol_class = PROTOCOL_MAP[response.headers['version']]
if type(self) is not protocol_class:
self.engine.protocol = protocol_class(self.engine)
self.engine.protocol.connect(frame, response=response)

The second CONNECTED is sent because STOMP11.connect() calls STOMP10.connect() via super (line 297 below):

def connect(self, frame, response=None):
connected_frame = Frame(frames.CONNECTED)
self._negotiate_protocol(frame, connected_frame)
heart_beat = frame.headers.get('heart-beat', '0,0')
if heart_beat:
self.enable_heartbeat(*map(int, heart_beat.split(',')), response=connected_frame)
super(STOMP11, self).connect(frame, response=connected_frame)

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

1 participant