How do I use web::block in a websocket application? #1455
-
My issue: all websocket requests in the example websocket_chat example, are blocking. This means that when I pass an r2d2 connection pool into my ChatServer actor, the query blocks all threads. Does anyone have I have a websocket app based very closely on the websocket_chat example, but I'm finding the thread is blocked when doing multiple actions that require using an r2d2 connection pool. In the r2d2 examples, it says to use web::block, but there's no examples of this working for a websocket application. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
This might be a relevant section, perhaps ws::Message::Text(text) => {
let m = text.trim().to_owned();
info!("Message received: {:?} from id: {}", &m, self.id);
self
.cs_addr
.send(StandardMessage {
id: self.id,
msg: m,
})
.into_actor(self)
.then(|res, _, ctx| {
match res {
Ok(res) => ctx.text(res),
Err(e) => {
error!("{}", &e);
}
}
actix::fut::ready(())
})
.wait(ctx);
} Its also been suggested that I use a |
Beta Was this translation helpful? Give feedback.
-
Actually it seems like the actual blocks are in the |
Beta Was this translation helpful? Give feedback.
-
Hey @dessalines , did you find any solution to this? |
Beta Was this translation helpful? Give feedback.
Hey @dessalines , did you find any solution to this?