Martchus / syncthingtray

Tray application and Dolphin/Plasma integration for Syncthing
https://martchus.github.io/syncthingtray/
Other
1.57k stars 43 forks source link

Configurable timeout for connection to Syncthing #78

Closed tomasz1986 closed 2 years ago

tomasz1986 commented 3 years ago

Relevant components

Environment and versions Syncthing Tray v1.0.1 (development build) Windows 10 Enterprise 2019 LTSC

Bug description I have Syncthing Tray configured on a Windows PC to connect to Syncthing on the local computer, and also on a few remote devices, which use local LAN addresses. It seems that the program is unable to detect connection changes on the remote devices. Basically, if I disconnect or shut Syncthing down on a remote device, Syncthing Tray still shows it as connected, and vice versa.

This is not the case on the local computer, where Syncthing Tray is running. As soon as Syncthing has been shut down or started, an icon update follows. The issue only happens with the remote devices. Am I doing something wrong or is this some kind of a bug or limitation?

My configuration is as follows.

Local machine (with Syncthing Tray, connection changes detected correctly) image

Remote machine (on the same LAN, unable to detect connection changes) image

Steps to reproduce

  1. Configure Syncthing Tray to connect to Syncthing on a remote device.
  2. Shut Syncthing down on the remote device.

Expected behavior Syncthing tray should detect whether Syncthing is still running, or has been started on remote devices, and then update its status accordingly.

Screenshots

Additional context

Martchus commented 3 years ago

This definitely works in general. I've just tested it with the Syncthing instance on my server and I've got a gray icon and disconnect notifications immediately. It works when stopping NGINX used as reverse proxy and it also works when stopping Syncthing itself.

Maybe it behaves differently under Windows.

tomasz1986 commented 3 years ago

Apparently I was partially wrong. I should have done more testing. I am sorry for that.

The icon does properly update after shutting Syncthing down. However, it does not if the device itself got disconnected from the network. The device is properly listed as "disconnected" in the Syncthing's GUI, but Syncthing Tray still seems to behave as if it was present.

One of the devices in question is running Android, just for reference. The other is running Windows. Syncthing Tray itself is running on another Windows computer. The problem happens both with the Android and the Windows device. If I disconnect them from the network (e.g. by turning their WiFi off), Syncthing Tray still marks the icon as "idle" and stays like that no matter what.

Martchus commented 3 years ago

This was never supposed to work that way. "Disconnected" in the sense of Syncthing Trays simply means "disconnected from Syncthing's REST/event API".

One of the devices [...] is running Android, [...] The other is running Windows. Syncthing Tray itself is running on another Windows computer. If I disconnect them from the network (e.g. by turning their WiFi off), Syncthing Tray still marks the icon as "idle" and stays like that no matter what.

Wait, your still talking about the overall status icon right? So the overall status icon should turn info the greyish "offline" as soon as at least one remote device is offline? Or if no remote devices are connected at all? Both makes not much sense to me. Isn't it quite normal that not all devices within the cluster are permanently online?

Or are you talking about the status within the "Devices" tab? Then I can not reproduce the problem.

tomasz1986 commented 3 years ago

No no, I am talking about the icon changing to grey when the Syncthing URL specified in the configuration is unavailable. As far as I understand, if this address is unavailable, the REST/event API is also inaccessible, is it not?

I am talking about this setting, i.e. nothing about the "Devices" tab, etc. I am sorry for any confusion.

image

To put it simply,

  1. Syncthing Tray is running on Device A (10.0.0.2) and is configured to connect to Syncthing running on Device B (10.0.0.6). The URL in the configuration is set to https://10.0.0.6:8384.

and there are two cases,

  1. Syncthing gets shut down on Device B. The tray icon on Device A changes to grey. This is expected. In the same vein, Syncthing gets started on Device B. The tray icon on Device A changes back from grey to colour. Also expected.

but then

  1. Device B itself gets shut down or disconnected from the network, without shutting down Syncthing explicitly first. The tray icon on Device A does not change to grey, even though the REST/event API under https://10.0.0.6:8384 is not accessible anymore. This is not expected.

The only difference between 2. and 3., which I can think of, is that in the former the IP address itself (10.0.0.6) remains always pingable, while in the latter the IP address is unavailable.

tomasz1986 commented 3 years ago

After more testing, this is how to reproduce:

  1. Start a fresh instance of Syncthing Tray.
  2. Set up a new configuration using a remote URL in the Syncthing URL, e.g https://10.0.0.6:8384.
  3. The remote URL is pingable and Syncthing Tray connects with it properly.

    >ping 10.0.0.6
    
    Pinging 10.0.0.6 with 32 bytes of data:
    Reply from 10.0.0.6: bytes=32 time=6ms TTL=64
    Reply from 10.0.0.6: bytes=32 time=2ms TTL=64
    Reply from 10.0.0.6: bytes=32 time=14ms TTL=64
    Reply from 10.0.0.6: bytes=32 time=19ms TTL=64
    
    Ping statistics for 10.0.0.6:
       Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
       Minimum = 2ms, Maximum = 19ms, Average = 10ms
  4. Syncthing Tray icon is coloured. image
  5. Disconnect the remote device from the network.

    >ping 10.0.0.6
    
    Pinging 10.0.0.6 with 32 bytes of data:
    Reply from 10.0.0.2: Destination host unreachable.
    Reply from 10.0.0.2: Destination host unreachable.
    Reply from 10.0.0.2: Destination host unreachable.
    Reply from 10.0.0.2: Destination host unreachable.
    
    Ping statistics for 10.0.0.6:
       Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
  6. Syncthing Tray icon stays coloured. image
Martchus commented 3 years ago

Ah, ok. I suppose in case 3. the timeout for the TCP connection is waited. I don't do anything special regarding timeout handling within my code so I guess the default timeout applies (possibly even set on OS level).

tomasz1986 commented 3 years ago

Do you have any idea of a possible workaround (either in Syncthing Tray, or at the user side)? Right now, there seems to be no timeout at all, as the icon stays like this forever, and I have not messed around with the default TCP connection related settings in Windows either.

Edit: It seems that after 2 hours or so the icon finally changed to grey, so there must be some kind of a timeout in place, but apparently awfully long.

Martchus commented 3 years ago

I don't know any workaround, especially not under Windows. Feel free to play around with it yourself. I am not aware that Qt would provide a way to set a timeout but one could likely simply use a timer to implement an early abort of the connection.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.