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

Send "stop" to trackers during shutdown #313

Closed
feross opened this issue May 11, 2015 · 5 comments
Closed

Send "stop" to trackers during shutdown #313

feross opened this issue May 11, 2015 · 5 comments

Comments

@feross
Copy link
Member

@feross feross commented May 11, 2015

The tracker protocol (and bittorrent-tracker) has a method to tell the tracker that a client is leaving the swarm, so the tracker can remove it's "ip:port" from the list of clients.

From the bittorrent-tracker API:

// stop getting peers from the tracker, gracefully leave the swarm
client.stop()

Let's do this.

@sudoaza

This comment has been minimized.

Copy link

@sudoaza sudoaza commented May 13, 2015

Is this as simple as calling self.stop() from WebTorrent.prototype.destroy ? or am i missing something?

@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented May 13, 2015

Probably 😄 You want to try your hand at a PR?

@sudoaza

This comment has been minimized.

Copy link

@sudoaza sudoaza commented May 13, 2015

i will!

UPDATE

:( too n00b for this, i thought we were already using bittorrent-tracker/client and was as simple as calling it.

Anyway, the stop event on the server is being called, check this out

 var tracker = new TrackerServer({ udp: false })

 tracker.listen(function () {
   var port = tracker.http.address().port
   var announceUrl = 'http://127.0.0.1:' + port + '/announce'
   leavesParsed.announce = [ announceUrl ]
 })

 tracker.on('stop', function(addr) {
   console.log('STOP HERE',addr)
 })

 var client1 = new WebTorrent({ dht: false })
 var torrent1 = client1.add(leavesParsed)
 torrent1.on('peer', function () {
   client1.destroy()
 })
@janza

This comment has been minimized.

Copy link
Contributor

@janza janza commented Jun 14, 2015

This seems to already be the case, it's called when torrent is removed

@feross

This comment has been minimized.

Copy link
Member Author

@feross feross commented Jun 24, 2015

@janza @sudoaza You guys are right. There may be a timing issue where the server doesn't get the 'stop' event if the client shuts down too quickly because we don't wait for confirmation. See here. There's no callback to wait for the response.

But I think this is okay. We don't want to delay the process exiting to wait for some slow, overloaded tracker on the other side of the world to respond to us.

@feross feross closed this Jun 24, 2015
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 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
3 participants
You can’t perform that action at this time.