diff --git a/async-nats/Cargo.toml b/async-nats/Cargo.toml index 3f03dc411..a14c2800d 100644 --- a/async-nats/Cargo.toml +++ b/async-nats/Cargo.toml @@ -17,14 +17,14 @@ categories = ["network-programming", "api-bindings"] memchr = "2.4" bytes = { version = "1.4.0", features = ["serde"] } futures = { version = "0.3.28", default-features = false, features = ["std"] } -nkeys = "0.3.1" +nkeys = "0.1" once_cell = "1.18.0" regex = "1.9.1" serde = { version = "1.0.184", features = ["derive"] } serde_json = "1.0.104" serde_repr = "0.1.16" http = "0.2.9" -tokio = { version = "1.29.0", features = ["macros", "rt", "fs", "net", "sync", "time", "io-util"] } +tokio = { version = "1.14", features = ["macros", "rt", "fs", "net", "sync", "time", "io-util"] } url = { version = "2"} tokio-rustls = "0.24" rustls-pemfile = "1.0.2" @@ -47,7 +47,7 @@ rustls = "0.21.6" # used by tokio-rustls 0.24.0 criterion = { version = "0.5", features = ["async_tokio"]} nats-server = { path = "../nats-server" } rand = "0.8" -tokio = { version = "1.25.0", features = ["rt-multi-thread"] } +tokio = { version = "1.14", features = ["rt-multi-thread"] } futures = { version = "0.3.28", default-features = false, features = ["std", "async-await"] } tracing-subscriber = "0.3" async-nats = {path = ".", features = ["experimental"]} diff --git a/async-nats/src/lib.rs b/async-nats/src/lib.rs index 45244189f..91c496faf 100644 --- a/async-nats/src/lib.rs +++ b/async-nats/src/lib.rs @@ -209,7 +209,7 @@ use std::slice; use std::str::{self, FromStr}; use std::task::{Context, Poll}; use tokio::io::ErrorKind; -use tokio::time::{interval, Duration, Interval, MissedTickBehavior}; +use tokio::time::{interval, Duration, Interval, MissedTickBehavior, interval_at, Instant}; use url::{Host, Url}; use bytes::Bytes; @@ -593,7 +593,7 @@ impl ConnectionHandler { } fn handle_server_op(&mut self, server_op: ServerOp) { - self.ping_interval.reset(); + self.ping_interval = interval_at(Instant::now(), self.ping_interval.period()); match server_op { ServerOp::Ping => { @@ -693,7 +693,9 @@ impl ConnectionHandler { } fn handle_command(&mut self, command: Command) { - self.ping_interval.reset(); + self.ping_interval = interval_at(Instant::now(), self.ping_interval.period()); + + match command { Command::Unsubscribe { sid, max } => {