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

Adding torrent without any error and then nothing happens #536

Closed
vinz243 opened this issue Dec 26, 2015 · 4 comments
Closed

Adding torrent without any error and then nothing happens #536

vinz243 opened this issue Dec 26, 2015 · 4 comments

Comments

@vinz243
Copy link
Contributor

@vinz243 vinz243 commented Dec 26, 2015

Here is my code that is supposed to add a torrent and download it:

// use this in promise
        var self = this;

        return new Promise((resolve, reject) => {
            if(!this._hash){
                this._state = State.INVALID;
                return reject(INVALID_ERROR());
            }

            // Do not init() twice
            if(this.isInitialized())
                return reject(new TypeError('Torrent '+self._hash+' is already initialized'));

            var parsed;
            try {
                parsed = parseTorrent(this._source);

            } catch(err) {
                return reject(err);
            }
            self._init = true;
            self._title = parsed.name || 'loading title...';
            self._state = State.LOADING;

            this.emit('change');
            this.emit('change:state');
            this.emit('initializing');

            this._torrent = this._config.client.add(this._source, (torr) => {
                console.log('TORRENT ADDED');
                this._state = State.CONNECTING;
                this.emit('change');
                this.emit('change:state');
                this.emit('connecting');
            });

            this._state = State.LOADING;

            this.emit('change');
            this.emit('change:state');
            this.emit('initialized');

            this._torrent.on('download', (chunkSize) => {
                if(!this.isDownloading()){
                    this._state = State.DOWNLOADING;
                    this.emit('change');
                    this.emit('change:state');
                    this.emit('downloading')
                }
                this.emit('download', chunkSize);
            });

            this._torrent.on('upload', (chunkSize) => {
                this.emit('upload', chunkSize);
            });

            this._torrent.on('error', (err) => {
                console.log('Error: ', err);
                this.emit('error', err);
            });

            this.on('download', this._onDownload);
            this.on('upload', this._onUpload);
            resolve({
                hash: this._hash,
                title: this._name
            });
        });

However it does not work (source: 'magnet:?xt=urn:btih:09e37f73e51f403bb543517f0d0a2e1283d61eb0&dn=archlinux-2015.12.01-dual.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce)

I mean, the torrent is added successfully, no error is thrown, but then nothing happens. No request is logged in the request log in chrome dev tools, no error in the console nothing. Any idea?

Thanks in advance,

(BTW here is the whole source https://github.com/vinz243/pTorrent/tree/features/lib)

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 27, 2015

It's hard to see what the issue might be looking at a random snippet from your codebase. Nothing stands out as obviously wrong.

You can enable debug logs across all of the various webtorrent packages by setting the DEBUG environment variable in your shell.

DEBUG=* node your-script.js

In the browser, you can do the same by running this in your console and refreshing the page:

localStorage.debug = '*'

This is documented here: https://github.com/feross/webtorrent#enable-debug-logs

Then, please paste the full debug output here and I can take a look.

@vinz243

This comment has been minimized.

Copy link
Contributor Author

@vinz243 vinz243 commented Dec 28, 2015

OK thanks! I just realized I need to use Node if I want UDP and TDP peers and not only WebRTC peers. I have another issue in node but it is not the place. Will open a new issue if you don't mind

@vinz243 vinz243 closed this Dec 28, 2015
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 28, 2015

Yep, that's right – the browser can only connect to WebRTC peers.

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 5, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.