websockets-rs / rust-websocket

A WebSocket (RFC6455) library written in Rust
http://websockets-rs.github.io/rust-websocket/
MIT License
1.55k stars 223 forks source link

Setting timeout on ClientBuilder::connect #151

Closed ParadoxSpiral closed 5 years ago

ParadoxSpiral commented 7 years ago

Currently you cannot seem to do this, so connecting to e.g. wss://1.1.1.1 takes ~2m30s. I use ws urls from user input, so it would be nice to be able to specify a timeout for the inital connecting.

illegalprime commented 6 years ago

@ParadoxSpiral is this async or sync? I think you can access the raw stream for sync and I believe there is a combinator for the async stuff, but it's good to add a convenience function.

illegalprime commented 6 years ago

oh I misread your issue, I see it now and I'll add it.

ParadoxSpiral commented 6 years ago

I do this now with a Timer with the async client for anyone who wants to do the same, but I still think that this would be a nice addition.

dbrgn commented 6 years ago

I would also like to see a configurable timeout without messing with timer futures :)

BlinkyStitt commented 5 years ago

@ParadoxSpiral can you share your code for using a timer on an async client?

ParadoxSpiral commented 5 years ago

@WyseNynja I use this timeout combinator from tokio.

ParadoxSpiral commented 5 years ago

Since there are other async utilities to achieve this I don't think it is necessary to add this feature, closing for now.

Lawliet-Chan commented 2 years ago

Since there are other async utilities to achieve this I don't think it is necessary to add this feature, closing for now.

I think you can make this timeout as a param in sync ClientBuilder, just like:

ClientBuilder::new(url, options{timeout: 500})