Skip to content

Reconnector will not be triggered when there is no onError parameter in the subscription processing #300

@Immanuel-Licht

Description

@Immanuel-Licht

Hi Elad,
I found the reconnector will not be triggered when there is no OnError parameter in the subscription process .

    public IWampRealmProxy Start(Dictionary<string, Action<IDictionary<string, ISerializedValue>>> subscribers)
    {
        var disposables = new List<IDisposable>();
        Reconnector = new WampChannelReconnector(_channel, async () =>
        {
            await _channel.Open().ConfigureAwait(false);
            disposables.ForEach(d => d.Dispose());
            disposables.Clear();
            foreach (var sub in subscribers)
            {
                var disposable = _channel.RealmProxy.Services.GetSubject(sub.Key).Subscribe(x =>
                 {
                     sub.Value?.Invoke(x.ArgumentsKeywords);
                 });
                disposables.Add(disposable);
            }
        });
        Reconnector.Start();
        return _channel.RealmProxy;
    }

I have to add OnError paramter in Subscribe method for the connector to run normally.

                var disposable = _channel.RealmProxy.Services.GetSubject(sub.Key).Subscribe(x =>
                 {
                     sub.Value?.Invoke(x.ArgumentsKeywords);
                 }, e =>
                 {
                     Console.WriteLine(e.ToString());
                 });

I think the reconnector should not be affected.
And it caused another problem, the reconnection will be triggered when I actively close the channel.So I have to dispose the reconnector when the channel is closed ,to avoid duplicate subscriptions.

    public async Task<GoodbyeMessage> Close(string reason = WampErrors.CloseNormal)
    {
        Reconnector.Dispose();
        return await _channel.Close(reason, new GoodbyeDetails());
    }

Is original design so or my code wrong?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions