Unexpected continuous DeviceReject events from the API with incrementing IDs


(xor-gate) #1

I’m trying to implement a native notification feature under OS X. All works fine except I get spammed with DeviceReject event by the API. For FolderReject it works fine (only once in a while a event as expected). See a trace below, hopefully it is helpfull. Maybe we are using it wrong, but I did read the documentation every event is generated by syncthing itself with a incrementing ID.

2018-07-05 22:34:05.745762+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "[fe80::e0e7:39ff:fed7:12cd%en1]:49716";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 587;
    id = 587;
    time = "2018-07-05T22:33:57.949805995+02:00";
    type = DeviceRejected;
}
2018-07-05 22:35:00.353231+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "[fe80::e0e7:39ff:fed7:12cd%en1]:49724";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 590;
    id = 590;
    time = "2018-07-05T22:34:58.049999319+02:00";
    type = DeviceRejected;
}

2018-07-05 22:39:37.322868+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "[fe80::e0e7:39ff:fed7:12cd%en1]:49756";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 603;
    id = 603;
    time = "2018-07-05T22:38:58.810907493+02:00";
    type = DeviceRejected;
}
2018-07-05 22:39:37.889730+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "185.194.141.93:22067";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 602;
    id = 602;
    time = "2018-07-05T22:38:57.786512907+02:00";
    type = DeviceRejected;
}
2018-07-05 22:39:38.929579+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "[fe80::e0e7:39ff:fed7:12cd%en1]:49748";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 599;
    id = 599;
    time = "2018-07-05T22:37:58.397312138+02:00";
    type = DeviceRejected;
}
2018-07-05 22:39:39.513555+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "[fe80::e0e7:39ff:fed7:12cd%en1]:49742";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 596;
    id = 596;
    time = "2018-07-05T22:36:58.280664525+02:00";
    type = DeviceRejected;
}
2018-07-05 22:39:40.121382+0200 Syncthing[27986:1877616] ui {
    data =     {
        address = "[fe80::e0e7:39ff:fed7:12cd%en1]:49734";
        device = "J5F2YGI-JS4NXTK-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY";
        name = boembats;
    };
    globalID = 593;
    id = 593;
    time = "2018-07-05T22:35:58.130836598+02:00";
    type = DeviceRejected;
}

(xor-gate) #2

Answering my own question, it seems when I don’t perform any action (in the webgui) the event is fired every N time. The webgui (later or dismiss) button actions modifies the state of the configuration. Then the notification event firing stops.

Why are we not able to ignore/dismiss those events from the API and only is the event filter implemented in javascript? Or I’m misunderstanding the code wrong.


(xor-gate) #3

Answering a little more after deep code diving:

When ignored from the webgui the configuration is updated using the API and ignored entries are added to the xml:

<ignoredDevice>ACACBAC-ACACACB-XTJFCUZ-4HKMHRM-ZY6W2GC-MZDVGLA-5TG7HEL-IWSCMAY</ignoredDevice>
<ignoredFolder>v4qj4-rwagd</ignoredFolder>

Over here:


(Jakob Borg) #4

The event is triggered on every rejected connection, unless it’s by a device ID we specifically ignore.


(xor-gate) #5

Yeah, after digging around I came to the same conclusion the announcing node polls for 60 seconds or so. But when added to the ignoredDevices using the webgui it works fine. So when implementing an notification with buttons I should need a Accept and Ignore. The ignore in the webgui just adds deviceID filter for the specific device?


(Jakob Borg) #6

Yep. Which you could do like it does, or add to your own config. The GUI doesn’t have somewhere of its own to store state.


(xor-gate) #7

This makes a lot more sense now. Thanks!


(xor-gate) #8

For people who read this here is the corresponding github issue ticket of the actual enhancement https://github.com/xor-gate/syncthing-macosx/issues/52


(Catfriend1) #9

Sidenote : I am currently implementing the accept/ignore button logic with Rest API POST behind the scene for the syncthing-android app. See https://github.com/syncthing/syncthing-android/pull/1177/files for the java code.


(xor-gate) #10

@Catfriend1 thanks for pointing this out, it seems every gui implements the accept/ignore logic on its own. Probably it must be moved into syncthing event system accessable from the REST API. Then there is one calling convention and just one wel defined implementation.