Skip to content

Js Mqtt - PR #7 Client implementation#703

Open
bretambrose wants to merge 21 commits into
JsMqtt-6-Protocolfrom
JsMqtt-7-Client
Open

Js Mqtt - PR #7 Client implementation#703
bretambrose wants to merge 21 commits into
JsMqtt-6-Protocolfrom
JsMqtt-7-Client

Conversation

@bretambrose
Copy link
Copy Markdown
Contributor

Client implementation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@bretambrose bretambrose marked this pull request as ready for review March 23, 2026 16:08
Comment thread lib/browser/mqtt_internal/client.ts Outdated
* Emitted when the client successfully establishes an MQTT connection to the remote endpoint
*/
export interface ConnectionSuccessEvent {
connack: mqtt5_packet.ConnackPacket,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No NegotiatedSettings?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not needed technically. Even if we did include it, I'd make it a clone of the locally-computed copy so that protocol state wasn't externally modifiable. Nothing stops us from adding it later if a reason comes up.

Copy link
Copy Markdown
Contributor

@sbSteveK sbSteveK left a comment

Choose a reason for hiding this comment

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

Some minor comments on the resubscribe stuff. Will move onto bulk of client next.

this.subscriptions.clear();
}

onSubscribeRequest(topicFilter: string, qos: mqtt5_packet.QoS) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Edge case:
User is offline with OfflineQueuePolicy set to never. Subscribe stores this before checking the policy. It's discarded. Once connection is established we send out a subscribe based on buildResubscribePacketList that shouldn't be sent due to OfflineQueuePolicy.

We submit a subscription but it's rejected (maybe permissions) but the sub is set before we process the suback. On a reconnect we attempt to resub despite it having failed the first time so we aren't really "resubscribing". This initial failure that is followed later on in a discon/recon may be a success due to some kind of permission or broker change. This one is less an issue but still probably possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Disagree that this is an issue. I think of this as capturing "intent". If the user wants to subscribe to X we will try to subscribe to X. If it fails, it fails, but by triggering off of subscribe/unsubscribe we stay true to original intent without having to track acks or additional bookkeeping that I don't think buys us anything useful.

this.subscriptions.set(topicFilter, qos);
}

onUnsubscribeRequest(topicFilter: string) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could probably use this to remove a subscription that failed if we get a negative suback for the second issue listed above.

Comment thread lib/browser/mqtt_internal/client.ts Outdated
Comment thread lib/browser/mqtt_internal/client.ts Outdated
Comment thread lib/browser/mqtt_internal/client.ts Outdated
*/
EnabledOnSessionResumptionFail,

Default = 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The default mode seems not be used at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While it's internal, the basic intention of the client interface is to be as if it were public.

Comment thread lib/browser/mqtt_internal/client.ts Outdated
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.

3 participants