emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.6k stars 419 forks source link

How to set subscription identifier when subcribe #524

Closed SkylineJia closed 1 year ago

SkylineJia commented 1 year ago

How to set subscriptionIdentifier when use mqtt5.subscribe?

leeway1208 commented 1 year ago

Hi. I will make an new interface to you.

SkylineJia commented 1 year ago

Subscribe to a topic with a subscription identifier. Then, the server closes the connection resulting in an error message "Remote peer has closed the socket". The error seems to stem from a four-byte issue in the code found at https://github.com/emqx/CocoaMQTT/blob/3fbf0e31827e3025cd7026e18ea83641a102333e/Source/FrameSubscribe.swift#L116 subscriptionIdentifier.byteArrayLittleEndian

According to the documentation found at https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901166, the subscription identifier should be a variable length byte.

leeway1208 commented 1 year ago

Hello, I will fix it ASAP . Or could you provide PR to us and help us to fix this issue? Thanks~