[Request] Schedule-based connection speed limits

Something that I think would be useful would be an ability to have different connection speed limits on a schedule… something like “limit traffic to X kbps during these hours, unlimited speed during these hours”. When transferring large files, it’s easy to let Syncthing saturate my Internet connection, so I have to adjust the incoming connection speed during business hours, either in the GUI or through the API. However at night I then remove the connection speed limit to let traffic flow unrestricted. Some form of built in support for that would be helpful, although maybe not to a large audience.

2 Likes

The API is your oyster.

1 Like

Hi Ryan

I have this same requirement. Did you get anywhere with a workaround or solution?

I have seen people asking for it but the proposed solutions tend to require scripted use of the API, etc, and they tend to look beyond my current level of technical ability.

I see that Resilio Sync has implemented this feature in its Home PRO version so am wondering if this may be my best option.

Thoughts or comments?

Thank you

Mark

Cooking recipe:

  • install syncthing.exe as service “syncthing”
  • load unixtools sed.exe to c:\windows
  • add a scheduled job to cron/windows scheduler
  • execute batch in job
  • net stop syncthing
  • sed -i -e s/Limit…=0/Limit…=100000/gI config.xml
  • net start syncthing

You can pass the limit as a command line parameter from the scheduled job. Have one job on the limit start hour and one job on the end hour to reset back to 0 ( = unlimited ).

1 Like

Or just use curl and jq with the REST Api, which will not force a complete rescan and will not close any connections:

curl -s -X GET -H 'X-API-Key: {api-key}' http://localhost:8384/rest/system/config | jq '.options.maxSendKbps = 1024 | .options.maxRecvKbps = 2048' | curl -s -X POST -H 'X-API-Key: {api-key}' http://localhost:8384/rest/system/config -d @-

not tested on Windows

https://curl.haxx.se/windows/
https://stedolan.github.io/jq/download/

You can even control these using the new cli

@wweich, this works like a charm. A thousand thank-you’s.

I tweaked the command line you provided, put it into two script files (one to increase receive rate, one to decrease) and then simply set the Synology Task Scheduler to execute each script at the right time of day.

Bingo!

Thank you again.

What new CLI? Are you talking about something other than the ‘syncthing’ command? I don’t see any options for changing bandwidth under 1.4.2 under Debian.

It’s not something that is shipped but you can download it off the official build servers under artifacts. The binary is called stcli.

https://build.syncthing.net/viewType.html?buildTypeId=Syncthing_Tools

4 Likes

That’s beautiful! I just deployed it and tested it on 30 servers. This is going to seriously help automating syncthing using a configuration management system.

1 Like

Now that the CLI is integrated into the Syncthing binary, the current way is

syncthing cli config options max-send-kbps set 50
syncthing cli config options max-recv-kbps set 50

In Linux, add those to a cron file. Works when executed as the same user as the service. (And possibly in other user contexts, but untested)

2 Likes