Hi!
I want to implement a websocket stress tool acording to and moded from the example of the websocket project under the actix_examples
I expect by setting the client timeout config or a recursivly reconnect founction to improve the success rate of client link server when server busy
first i set the client config through the
async{
....
let (_,framed)=client::build()
.timeout(Duration::from_secs(15))
.finish()
.ws("htpp://127.0.0.1:8080/ws/")
.connect()
.await
....
}
but when the server got busy the timeout config setting doesn't take effect, after 5s the 408 status was returned
so i try to implement a asyncly reconnect function acording to the async doc
the code like that :
use futures::future::{BoxFuture, FutureExt};
fn recursive(c:&Client ) -> BoxFuture<'static, Framed<BoxedSocket,Codec>> {
async move {
let ret0=c.ws(...)
.connect()
.await;
match ret0{
OK((_,framed))=>{framed}
_=> {
delay_for(Duration::from_secs(5)).await;
reconnect(c).await
}
}
}.boxed()
}
but the compiler complained a lot of errors such like :
> .boxed()
> ^^^^ `std::rc::Rc<awc::ClientConfig>` cannot be sent between threads safely
which is quite confusing to me because there are no such type in the context but i guess this must be related with the coroutine yielded value type by the await;
,plaese help me get through of this
Best Regards
hardware: macbook pro 2.6G 6 cores intel i7 16GBRAM 512GB SSD;
op sys: macos mojave 10.14.6;
rustc -V): rustc 1.39.0@zhaohansprt .boxed() produces BoxFuture, which contains Send requirement. Try to use .boxed_local().
@zhaohansprt
.boxed()producesBoxFuture, which containsSendrequirement. Try to use.boxed_local().
very nice it works
Most helpful comment
very nice it works