Skip to content

Commit

Permalink
Updated fabruic + removed idle timeout
Browse files Browse the repository at this point in the history
This makes the QUIC connections behave similarly to the WebSocket
connections by not timing out automatically. However, this is a band-aid
and a full solution is being suggested in #116
  • Loading branch information
ecton committed Dec 12, 2021
1 parent 5aa1a68 commit 2ee96a2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/bonsaidb-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ wasm-bindgen-futures = "0.4"
wasm-bindgen = "0.2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
fabruic = { version = "0.0.1-dev.3" }
fabruic = { version = "0.0.1-dev.4" }
tokio = { version = "1", features = ["sync"] }
tokio-tungstenite = { version = "0.16", optional = true, features = [
"rustls-tls-native-roots",
Expand Down
7 changes: 6 additions & 1 deletion crates/bonsaidb-client/src/client/quic_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ async fn connect<A: CustomApi>(
),
Error<A::Error>,
> {
let endpoint = Endpoint::new_client()
let mut endpoint = Endpoint::builder();
endpoint
.set_max_idle_timeout(None)
.map_err(|err| Error::Core(bonsaidb_core::Error::Transport(err.to_string())))?;
let endpoint = endpoint
.build()
.map_err(|err| Error::Core(bonsaidb_core::Error::Transport(err.to_string())))?;
let connecting = if let Some(certificate) = certificate {
endpoint.connect_pinned(url, certificate, None).await?
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ itertools = "0.10"
tokio-tungstenite = { version = "0.16", optional = true }
bincode = { version = "1", optional = true }
pot = "0.1.0-alpha.3"
fabruic = { version = "0.0.1-dev.3", features = ["dangerous"] }
fabruic = { version = "0.0.1-dev.4", features = ["dangerous"] }
cfg-if = "1"
pem = { version = "1", optional = true }
async-acme = { version = "0.3", optional = true, features = ["hyper_rustls"] }
Expand Down
11 changes: 9 additions & 2 deletions crates/bonsaidb-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,15 @@ impl<B: Backend> CustomServer<B> {
let certificate = self.tls_certificate().await?;
let keypair =
KeyPair::from_parts(certificate.certificate_chain, certificate.private_key.0)?;

let mut server = Endpoint::new_server(port, keypair)?;
let mut builder = Endpoint::builder();
builder.set_address(([0; 8], port).into());
builder
.set_max_idle_timeout(None)
.map_err(|err| Error::Core(bonsaidb_core::Error::Transport(err.to_string())))?;
builder.set_server_key_pair(Some(keypair));
let mut server = builder
.build()
.map_err(|err| Error::Core(bonsaidb_core::Error::Transport(err.to_string())))?;
{
let mut endpoint = self.data.endpoint.write().await;
*endpoint = Some(server.clone());
Expand Down

0 comments on commit 2ee96a2

Please sign in to comment.