GithubHelp home page GithubHelp logo

Comments (8)

bbijelic avatar bbijelic commented on July 19, 2024 2

FYI, finally managed to run it successfully via magnet link (torrent file case still to be checked) :)

  1. Verified that CLI app is downloading via magnet link (on CentOS VM)
  2. Running CLI on Windows is throwing exception:
Exception in thread "main" java.lang.RuntimeException: Failed to create terminal
        at bt.cli.SessionStatePrinter.<init>(SessionStatePrinter.java:106)
        at bt.cli.SessionStatePrinter$1.<init>(SessionStatePrinter.java:40)
        at bt.cli.SessionStatePrinter.createKeyInputAwarePrinter(SessionStatePrinter.java:40)
        at bt.cli.CliClient.<init>(CliClient.java:131)
        at bt.cli.CliClient.main(CliClient.java:56)
Caused by: java.io.IOException: Cannot run program "/bin/stty": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.exec(UnixLikeTTYTerminal.java:169)
        at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.saveTerminalSettings(UnixLikeTTYTerminal.java:117)
        at com.googlecode.lanterna.terminal.ansi.UnixLikeTerminal.aquire(UnixLikeTerminal.java:79)
        at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.realAquire(UnixLikeTTYTerminal.java:87)
        at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.<init>(UnixLikeTTYTerminal.java:78)
        at com.googlecode.lanterna.terminal.ansi.CygwinTerminal.<init>(CygwinTerminal.java:59)
        at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createCygwinTerminal(DefaultTerminalFactory.java:293)
        at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createWindowsTerminal(DefaultTerminalFactory.java:288)
        at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createTerminal(DefaultTerminalFactory.java:98)
        at bt.cli.SessionStatePrinter.<init>(SessionStatePrinter.java:93)
        ... 4 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 15 more
  1. Since CLI is working, I have checked into source code to see how it is actually setup there, and did the same. First initialized BtRuntime and then passed it into the client builder:
// enable multithreaded verification of torrent data
Config config = new Config() {

	@Override
	public int getNumOfHashingThreads() {
		return Runtime.getRuntime().availableProcessors();
	}
};

// enable bootstrapping from public routers
Module dhtModule = new DHTModule(new DHTConfig() {
	@Override
	public boolean shouldUseRouterBootstrap() {
		return true;
	}

});

// Runtime
BtRuntime runtime = BtRuntime.builder(config).module(dhtModule).autoLoadModules().disableAutomaticShutdown()
		.build();

// Magnet link
String magnetLink = "magnet:?xt=urn:btih:2b32e64f6cd755a9e54d60e205a9681d6670cfae";

// Storage
Storage storage = new FileSystemStorage(new File("C:\\Users\\Snijele\\Desktop\\TEST\\").toPath());

// Client
BtClient client = Bt.client(runtime).storage(storage).magnet(magnetLink).build();

// launch
client.startAsync(state -> {
	if (state.getPiecesRemaining() == 0) {
		client.stop();
	}
}, 1000).join();

and this works like a charm. :)

Summary:

  • Example in README file does not work
  • Building client without passing BtRuntime does not start download

Thank you for your support!
Cheers mate!

from bt.

atomashpolskiy avatar atomashpolskiy commented on July 19, 2024

Hi @bbijelic ,

You should enable bootstrapping from the public DHT nodes or provide the list of your own. Please see the full usage example in the project's readme. Picture with code is a bit misleading, I need to update it.

from bt.

bbijelic avatar bbijelic commented on July 19, 2024

Thanks for suggestion, tried with enabling bootstrapping from public DHT nodes - but no success, problem persists.

// enable multithreaded verification of torrent data
Config config = new Config() {
    @Override
    public int getNumOfHashingThreads() {
        return Runtime.getRuntime().availableProcessors() * 2;
    }
};

// enable bootstrapping from public routers
Module dhtModule = new DHTModule(new DHTConfig() {
    @Override
    public boolean shouldUseRouterBootstrap() {
        return true;
    }
});

String magnetLink = "magnet:?xt=urn:btih:2b32e64f6cd755a9e54d60e205a9681d6670cfae";
Storage storage = new FileSystemStorage(new File("C:\\Users\\Snijele\\Desktop\\TEST").toPath());
BtClient client = Bt.client()
	.config(config)
	.storage(storage)
	.magnet(magnetLink)
	.autoLoadModules()
	.module(dhtModule)
	.build();

// launch
client.startAsync(state -> {
	if (state.getPiecesRemaining() == 0) {
		client.stop();
	}
}, 1000).join();

Tried same for the torrent file case, also no success, although, for torrent file, it shows following in the log, and after that just hangs...:

12:10:35.049 [bt.service.executor-thread-1] DEBUG bt.processor.ChainProcessor - Processing next stage: torrent ID (462101aa44b2e058f6f931bffe8d49531aa40ca8), stage (bt.processor.torrent.ProcessTorrentStage)
12:10:35.088 [bt.service.executor-thread-1] DEBUG bt.tracker.udp.UdpTracker - Executing tracker UDP request of type START: AnnounceRequest{id=-1000147074, torrentId=462101aa44b2e058f6f931bffe8d49531aa40ca8, peerId=[45, 66, 116, 1, 4, 0, 1, 45, -81, 36, 65, 118, -107, 19, -73, -81, 74, 50, -60, 37], downloaded=0, left=0, uploaded=0, eventType=START(2), listeningPort=0, requestString=/announce}
12:10:35.090 [bt.tracker.udp.message-worker] DEBUG bt.tracker.udp.UdpMessageWorker - Creating UDP socket {localAddress=0.0.0.0/0.0.0.0:0}
12:10:35.092 [bt.tracker.udp.message-worker] DEBUG bt.tracker.udp.UdpMessageWorker - Connecting UDP socket {localAddress=0.0.0.0/0.0.0.0:0, remoteAddress=eddie4.nl/87.233.192.220:6969}

I have buit library from source in meantime. Here are my dependencies:

<dependencies>
	<dependency>
		<groupId>com.github.atomashpolskiy</groupId>
		<artifactId>bt-http-tracker-client</artifactId>
		<version>1.4-SNAPSHOT</version>
	</dependency>
	<dependency>
		<groupId>com.github.atomashpolskiy</groupId>
		<artifactId>bt-core</artifactId>
		<version>1.4-SNAPSHOT</version>
	</dependency>
	<dependency>
		<groupId>com.github.atomashpolskiy</groupId>
		<artifactId>bt-dht</artifactId>
		<version>1.4-SNAPSHOT</version>
	</dependency>
</dependencies>

PS. forgot to mention that client Consumer instance is triggered every 1000ms as configured.

from bt.

atomashpolskiy avatar atomashpolskiy commented on July 19, 2024

In case with using .torrent file it seems like the client is not discovering any peers. Also, eddie4.nl looks like a private tracker, and if so, then bootstrapping from public DHT will have no effect -- for private torrents only the tracker is queried for peers. Can you confirm if this is a private/public torrent and if the tracker returns any peers?
Full log with trace enabled might be helpful.

In case with using a magnet link, logs show that the metadata has been fetched. This means that:

  1. DHT peer lookup was successful
  2. You've been able to connect to some of the peers and download metadata
  3. You just have to wait until some of the peers unchokes you

from bt.

atomashpolskiy avatar atomashpolskiy commented on July 19, 2024

Just tried downloading with CLI:
java -jar bt-launcher.jar -m "magnet:?xt=urn:btih:2b32e64f6cd755a9e54d60e205a9681d6670cfae" -d ~/Downloads/rt
It works:

Downloading World of Warcraft 1.12 Client.rar (5 450 407 230 B)
----------------------------------------------------------------
Elapsed time: 0:02:39       Remaining time: 46:11:09
Peers: 12       Down: 32,0 KB/s 

from bt.

atomashpolskiy avatar atomashpolskiy commented on July 19, 2024

Updated my initial comment

from bt.

atomashpolskiy avatar atomashpolskiy commented on July 19, 2024
DEBUG bt.tracker.udp.UdpTracker - Executing tracker UDP request of type START: AnnounceRequest{..., listeningPort=0, ...}

Oh, this is actually a bug, client should provide the actual listening port to the UDP tracker.. I just pushed to the fix to master.

This might have affected peer discovery in case with .torrent file (effectively preventing other peers from connecting to you, if they discovered you via the tracker). It's unlikely to be the root cause of your problem though.

from bt.

atomashpolskiy avatar atomashpolskiy commented on July 19, 2024

I tracked down the cause, turned out that the standalone client was not initializing the runtime properly due to a programming error. I've pushed the fix along with some internal refactoring. Public API haven't changed.

It's good that you've reported the bug, it was really subtle, and I can only wonder how many folks had run into the same problem before :)

Running CLI on Windows is throwing exception

Yeah, it's actually a known issue. GUI framework that I'm using does not support Windows, so the CLI should be run in headless mode there (-H flag)


Considering your latest code: you might want to enable automatic runtime shutdown if the download is one-off task (i.e. you are not starting multiple clients in the same runtime). Otherwise the runtime will keep on wasting cycles (peer lookups, DHT agent, message loop, etc.) and will terminate only on JVM shutdown.

Again, thanks for reporting and for your patience, user feedback is very important to me.

from bt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.