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

Multiple executions of callbacks on client downlinks #70

Open
DobromirM opened this issue Oct 1, 2021 · 1 comment
Open

Multiple executions of callbacks on client downlinks #70

DobromirM opened this issue Oct 1, 2021 · 1 comment
Labels
C-bug Category: bug

Comments

@DobromirM
Copy link
Member

The callbacks of downlinks opened using the swim client are being executed multiple times.

Tested with a map downlink with didUpdate callback and a value downlink with a didSet callback.

@DobromirM DobromirM added the C-bug Category: bug label Oct 1, 2021
@ajay-gov
Copy link
Member

ajay-gov commented Oct 1, 2021

This is expected behavior. These multiple executions are due to the client reconnecting (this is due to an idle connection). So it resyncs and gets the data back. If the connection is not idle, i.e if there are messages in transit then this won't happen. You can confirm by logging the didConnect callbacks. Also the way to work around it is to do the following:

    final MapDownlink<Uri, Uri> downlink = downlinkMap()
        .keyForm(Uri.form())
        .valueForm(Uri.form())
        .hostUri(hostUri)
        .nodeUri(nodeUri())
        .laneUri(laneUri)
        .keepSynced(true);
    downlink.open()
        .didConnect(() -> {
          info(nodeUri() + ": Did connect to host:" + hostUri + ", node: " + nodeUri() + ", lane: " + laneUri);
        })
        .didSync(() -> {
          downlink.keepSynced(false);
        })
        .didUpdate((key, newValue, oldValue) -> {
          info(nodeUri() + ": Did update");
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants