question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need help changing max upload speed while seeding

See original GitHub issue

Hey!

I need some help changing the MaxUploadSpeed after/while seeding please.

This is basically the code I am using to start seeding. It’s more like an on demand seeding option so one can click Seed and only then the seeding will start:

private async void button_Seeding_Click(object sender, EventArgs e)
        {
            // Give an example of how settings can be modified for the engine.
            var settingBuilder = new EngineSettingsBuilder
            {
                AllowPortForwarding = true,
                AutoSaveLoadDhtCache = true,
                AutoSaveLoadFastResume = true,
                AutoSaveLoadMagnetLinkMetadata = true,
                AllowLocalPeerDiscovery = true,
                MaximumConnections = 300,

            };

            var torrent = await Torrent.LoadAsync(torrentfile);
            dhtEngine = new DhtEngine(new IPEndPoint(IPAddress.Any, 0));
            TorrentEngine = new ClientEngine(settingBuilder.ToSettings());
            manager = await TorrentEngine.AddAsync(torrent, currentinstalldir);
            manager.TorrentStateChanged += Manager_TorrentStateChanged1;

            await dhtEngine.StartAsync();
            await manager.StartAsync();
        }

private void Manager_TorrentStateChanged1(object sender, TorrentStateChangedEventArgs e)
        {
            while (manager.State == TorrentState.Seeding)
            {
                manager.LocalPeerAnnounceAsync();
                manager.DhtAnnounceAsync();

                label_seeding.Text = manager.State + "... " + ConvertBytesToMegabytes(manager.Monitor.UploadSpeed).ToString("0.00" + " MB/s");
               
            }
        }

From here the torrent starts seeding at full speed as expected, but I would like to make use either a textbox or NumericUpDown in Windows Forms to be able to change the max upload speed while seeding. I just don’t know where and how to implement this. Any help will be much appreciated!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alanmcgoverncommented, Nov 6, 2022

Ah yeah, the joys of writing code in comments instead of an IDE.

    var settingsBuilder = new TorrentSettingsBuilder (manager.Settings);
    settingsBuilder.MaximumUploadSpeed = uploadSpeedInBytesPerSecond;
    var settings = settingsBuilder.ToSettings ();
    await manager.UpdateSettingsAsync (settings);

@uponatime2019 had it right - you need to call .ToSettings() on the builder. Sorry for the confusion!

NOTE: If you constantly create a new ‘SettingsBuilder’ without passing in the old settings, you’ll lose any settings you set previously. You should always initialise the TorrentSettingsBuilder (or EngineSettingsBuilder) with a copy of the settings you want to modify/update. This is typically TorrentManager.Settings or ClientEngine.Settings.

0reactions
rjclarkewp007commented, Nov 5, 2022

So i used this which i found in another thread:

public async Task UpdateUploadSpeed(int uploadSpeedInBytesPerSecond)
        {
            TorrentSettings setmaxupload = new TorrentSettingsBuilder
            {

                MaximumUploadSpeed = uploadSpeedInBytesPerSecond,

            }.ToSettings();
            await manager.UpdateSettingsAsync(setmaxupload);
        }

The on the numeric up down button I am using this:

private async void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {

            int uploadSpeedInBytesPerSecond = Convert.ToInt32(Math.Round(numericUpDown1.Value * 1000000, 0));
            await UpdateUploadSpeed(uploadSpeedInBytesPerSecond);
        }

I used numericUpDown1.Value * 1000000 to get from bytes to megabytes. Hope that works. I still need to test it though. Running on a mobile network now so cannot test really 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to increase upload speed when seeding a specific file
Hello everyone, I recently joined a tracker that requires me to seed the torrents for an amount of time, I already finished downloading...
Read more >
Low upload speed when seeding · Issue #684 · qbittorrent ...
Low upload speed when seeding #684 ... If downloading reducing the download max rate will increase the upload max rate possible.
Read more >
Upload speed - seeding/leeching - Help and Support
Go to Bandwidth view and click Presets button. There you can add bandwidth presets and use them as seeding and downloading defaults. Tixati...
Read more >
Optimising seeding speed for upload 10Mb/s (Currently ...
1. Changing alternate upload speed when not downloading to 0 · 2. Changing Global maximum no. connections to 1000 and max no. ·...
Read more >
Settings to Optamize Seeding when Uploading?
Reduce maximum connections per torrent if you want higher seeding speeds...that way your upload is not split between so many peers. (Do this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found