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

Limit number of outgoing connections #348

Open
To-Azamat opened this issue Nov 12, 2024 · 9 comments
Open

Limit number of outgoing connections #348

To-Azamat opened this issue Nov 12, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@To-Azamat
Copy link

Is your feature request related to a problem? Please describe

When active and crawling BM opened thousands of outgoing UDP connections triggering ISP limit and making internet access for other clients unreachable.

Describe the solution you'd like

Add a setting to limit a number of active outgoing connections.

@To-Azamat To-Azamat added the enhancement New feature or request label Nov 12, 2024
@denniskrol
Copy link

#299

@felipemarinho97
Copy link

felipemarinho97 commented Dec 18, 2024

This may be a good solution

@demogorgonz
Copy link

Any other options instead of reducing dht_crawler.scaling_factor ?

I tried setting it to 5 and after some time got same results as #299 (comment) :

the number of connections went up again in about 2 hours

Just tried setting the value to 1 and will see how it goes.

Saw that VPN might be possible fix but that doesn't seem like great solution..

@demogorgonz
Copy link

demogorgonz commented Mar 21, 2025

Ok this seems to work in docker compose:

services:
  bitmagnet:
    image: ghcr.io/bitmagnet-io/bitmagnet:latest
    ulimits:
      nofile:
        soft: 1024
        hard: 2048
    container_name: bitmagnet
    ports:
      # API and WebUI port:
      - "3333:3333"
      # BitTorrent ports:
      - "3334:3334/tcp"
      - "3334:3334/udp"
    restart: unless-stopped
    environment:
      - POSTGRES_HOST=postgres
      - POSTGRES_PASSWORD=XXXXXXXXXXX
      - DHT_CRAWLER_SCALING_FACTOR=2
...

By setting low ulimits my router is not bombarded with UDP connections, this part exactly:

    ulimits:
      nofile:
        soft: 1024
        hard: 2048

Also reduced DHT_CRAWLER_SCALING_FACTOR to 2, will monitor how it behave.

@To-Azamat
Copy link
Author

ulimits:
  nofile:
    soft: 1024
    hard: 2048

Are those documented somewhere?

@demogorgonz
Copy link

demogorgonz commented Mar 21, 2025

ulimits:
  nofile:
    soft: 1024
    hard: 2048

Are those documented somewhere?

Documented where? BitMagnet, Docker, or Linux ? For Docker and Linux use google/search for general info.
Feel free to play with values too, this is just a way to limit number of connections in container until this get fixed in BitMagnet/DHT_Crawler.

@DerBunteBall
Copy link

See

man ulimit

on your system for technical documentation about the Linux basics.

Compose Reference for docker-compose specific stuff. It's a service level element. Just search for ulimits here.

@To-Azamat
Copy link
Author

ulimits:
  nofile:
    soft: 1024
    hard: 2048

It works, partly. I set those to 512-1024 and also a rule at router firewall to drop any outgoing UDP connections from bitmagnet exceeding 1024. Got 170k dropped connections in 9 hours. Still better than before, but hardly a solution.

@demogorgonz
Copy link

demogorgonz commented Mar 26, 2025

ulimits:
  nofile:
    soft: 1024
    hard: 2048

It works, partly. I set those to 512-1024 and also a rule at router firewall to drop any outgoing UDP connections from bitmagnet exceeding 1024. Got 170k dropped connections in 9 hours. Still better than before, but hardly a solution.

I have ended up with following values:

    ulimits:
      nofile:
        soft: 512
        hard: 768

My network seems stable, no more disconnects and other issues.

Edit:
Agreed it is not a proper solution, we need config/parameter to limit number of connections in BitMagnet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants