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

[FIXED] MQTT fixes and improvements #2178

Merged
merged 2 commits into from May 5, 2021
Merged

[FIXED] MQTT fixes and improvements #2178

merged 2 commits into from May 5, 2021

Conversation

kozlovic
Copy link
Member

@kozlovic kozlovic commented May 4, 2021

Some issues that have been fixed would manifest by timeouts on
connect, unexpected memory usage on high publish message rate.

Some details:

  • Replies were not always GW routed properly because we were looking
    at the wrong connection's rsubs
  • GW routed replies would not be found because they were tracked
    in the subscription's client object, which may not be the same used
    to send the reply
  • Increased the mqtt timeout to wait for JS replies since in some
    tests it was sometimes taking more than the original 2 seconds
  • Incoming gateway messages destined for an MQTT internal subscription
    may have been rejected as a no interest if the account had service imports
  • Don't use time.After(), instead create explicit timer so it can
    be stopped when not timing out.
  • Unnecessary copy of a slice since we were converting to a string anyway.

Signed-off-by: Ivan Kozlovic ivan@synadia.com

server/gateway.go Outdated Show resolved Hide resolved
server/gateway.go Outdated Show resolved Hide resolved
server/gateway.go Outdated Show resolved Hide resolved
server/gateway.go Outdated Show resolved Hide resolved
server/gateway.go Outdated Show resolved Hide resolved
Copy link
Contributor

@matthiashanel matthiashanel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - But I have limited familiarity with the code

Some issues that have been fixed would manifest by timeouts on
connect, unexpected memory usage on high publish message rate.

Some details:
- Replies were not always GW routed properly because we were looking
at the wrong connection's rsubs
- GW routed replies would not be found because they were tracked
in the subscription's client object, which may not be the same used
to send the reply
- Increased the mqtt timeout to wait for JS replies since in some
tests it was sometimes taking more than the original 2 seconds
- Incoming gateway messages destined for an MQTT internal subscription
may have been rejected as a no interest if the account had service imports
- Don't use time.After(), instead create explicit timer so it can
be stopped when not timing out.
- Unnecessary copy of a slice since we were converting to a string anyway.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
@kozlovic kozlovic changed the title [FIXED] Some issues with MQTT timeouts during connect [FIXED] MQTT fixes and improvements May 5, 2021
@kozlovic
Copy link
Member Author

kozlovic commented May 5, 2021

@derekcollison I have been reworking all that quite a bit and rebased from main, sorry about that. The main change has been to keep the gw reply mapping in the client object for CLIENT connections, and to account for others. I have extracted the client's gwrm/cgwrt to its own struct so that code can be reused between client/account, etc..

This will solve the issue of naming the durable per server for
the "retained messages" stream in situation where a cluster
of servers would not have JetStream defined but connect to another
cluster that has it. All the servers within the cluster without
JetStream would cause the durable's delivery subject to be updated
to the last server starting the durable.

Updated the check for mqtt requiring JetStream if running in
standalone mode to check that no leafnode configuration is present.

Replaced use of fmt.Errorf() when the string was static with
errors created with errors.New(). Updated tests that were checking
for errors to use those errors instead of repeating the string.

Added test that has a hub cluster with JS enabled and a remote server
that has mqtt{} without JetStream and ensure that this works.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kozlovic kozlovic merged commit 9eb12b6 into master May 5, 2021
@kozlovic kozlovic deleted the mqtt_updates branch May 5, 2021 22:39
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

3 participants