diff --git a/src/common/lib/client/realtimechannel.ts b/src/common/lib/client/realtimechannel.ts index ce6f50d687..615ab6a686 100644 --- a/src/common/lib/client/realtimechannel.ts +++ b/src/common/lib/client/realtimechannel.ts @@ -185,7 +185,20 @@ class RealtimeChannel extends Channel { } _shouldReattachToSetOptions(options?: API.Types.ChannelOptions) { - return (this.state === 'attached' || this.state === 'attaching') && (options?.params || options?.modes); + if (!(this.state === 'attached' || this.state === 'attaching')) { + return false; + } + if (options?.params) { + if (!this.params || !Utils.shallowEquals(this.params, options.params)) { + return true; + } + } + if (options?.modes) { + if (!this.modes || !Utils.arrEquals(options.modes, this.modes)) { + return true; + } + } + return false; } publish(...args: any[]): void | Promise { diff --git a/test/realtime/channel.test.js b/test/realtime/channel.test.js index 252a9b1ef6..a079b64062 100644 --- a/test/realtime/channel.test.js +++ b/test/realtime/channel.test.js @@ -647,7 +647,9 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async try { realtime.channels.get(testName, { - params: params, + params: { + modes: 'subscribe', + }, }); } catch (err) { try { @@ -714,7 +716,9 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async var setOptionsReturned = false; channel.setOptions( { - params: params, + params: { + modes: 'publish', + }, }, function () { /* Wait a tick so we don' depend on whether the update event runs the @@ -743,7 +747,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async var setOptionsReturned = false; channel.setOptions( { - modes: modes, + modes: ['subscribe'], }, function () { Ably.Realtime.Platform.Config.nextTick(function () {