Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

start and stop accepting connections #34

Closed
pgte opened this issue Apr 23, 2018 · 12 comments
Closed

start and stop accepting connections #34

pgte opened this issue Apr 23, 2018 · 12 comments

Comments

@pgte
Copy link

pgte commented Apr 23, 2018

To allow denying new connections before they're established, the transport interface must expose a way to stop accepting new connections, as well as start accepting them again.

First discussed here.

The proposed API here is adding two methods .start() and .stop().
For backwards compatibility, by default, the transport starts in the "accepts connections" state.

@daviddias
Copy link
Member

I feel this belongs to libp2p-switch. A Transport will always yield the connection to the switch which then handles it to SECIO. Before that happens, the connection can be terminated.

@pgte
Copy link
Author

pgte commented Apr 23, 2018

@diasdavid The thought crossed my mind. This would have the benefits of being simpler to implement (only one package touched).

I would argue that, since there may exist a significant overhead of establishing the raw connection for each transport, it would be beneficial to be able to prevent connections from happening in the first place. I believe this could be mostly significant in the case of webrtc..

@daviddias
Copy link
Member

daviddias commented Apr 23, 2018

@pgte good point. So in fact what you want is the ability to stop the listeners and start them back again at a later time. This is possible today from the interface-transport, just needs to be used accordingly in the switch.

@pgte
Copy link
Author

pgte commented Apr 23, 2018

@diasdavid yes, but wouldn't stopping a listener, (at least in some transports), also destroy all the underlying connections?

@daviddias
Copy link
Member

It doesn't destroy (or shouldn't) it actually waits for them to close and rejects new ones meanwhile.

@pgte
Copy link
Author

pgte commented Apr 23, 2018

Here, in the websocket-star protocol, it definitely closes the connection to the relay/discovery server: https://github.com/libp2p/js-libp2p-websocket-star/blob/master/src/listener.js#L77-L85

@pgte
Copy link
Author

pgte commented Apr 23, 2018

Which would, AFAIK, terminate all the underlying relayed connections..

@daviddias
Copy link
Member

@pgte that's a bug then :)

@pgte
Copy link
Author

pgte commented Apr 23, 2018

OK, filed issue here: libp2p/js-libp2p-websocket-star#49

@pgte pgte closed this as completed Apr 23, 2018
@daviddias
Copy link
Member

Thanks. Also track the work needed on libp2p-switch.

@pgte
Copy link
Author

pgte commented Apr 23, 2018

Also a bug in libp2p-tcp: libp2p/js-libp2p-tcp#92

@pgte
Copy link
Author

pgte commented Apr 23, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants