Skip to content

Commit 056a5e5

Browse files
Nickztarhenil
andauthored
feat(rumqttd): Support for websocket connections (#633)
--------- Co-authored-by: Henil Dedania <[email protected]>
1 parent 97d2784 commit 056a5e5

File tree

10 files changed

+104
-616
lines changed

10 files changed

+104
-616
lines changed

Cargo.lock

+14-110
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rumqttd/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11-
11+
- Support for Websocket connections (#633)
1212
### Changed
1313

1414
### Deprecated

rumqttd/Cargo.toml

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ tokio-rustls = { version = "0.24", optional = true }
2222
rustls-webpki = { version = "0.100.1", optional = true }
2323
tokio-native-tls = { version = "0.3", optional = true }
2424
rustls-pemfile = { version = "1", optional = true }
25-
tokio-tungstenite = { version = "0.15.0", optional = true }
26-
websocket-codec = { version = "0.5.1", optional = true }
25+
async-tungstenite = { version = "0.22.2", default-features = false, features = ["tokio-runtime"], optional = true }
26+
ws_stream_tungstenite = { version = "0.10.0", default-features = false, features = ["tokio_io"], optional = true }
2727
x509-parser = {version= "0.9.2", optional = true}
2828
futures-util = { version = "0.3.16", optional = true}
2929
parking_lot = "0.11.2"
@@ -37,9 +37,10 @@ axum = "0.6.4"
3737

3838
[features]
3939
default = ["use-rustls"]
40-
use-rustls = ["dep:tokio-rustls", "dep:rustls-webpki", "dep:rustls-pemfile", "dep:x509-parser"]
41-
use-native-tls = ["dep:tokio-native-tls", "dep:x509-parser"]
42-
websockets = ["dep:tokio-tungstenite", "dep:websocket-codec", "dep:tokio-util", "dep:futures-util"]
40+
use-rustls = ["dep:tokio-rustls", "dep:rustls-webpki", "dep:rustls-pemfile", "dep:x509-parser", "async-tungstenite?/tokio-rustls-native-certs"]
41+
use-native-tls = ["dep:tokio-native-tls", "dep:x509-parser", "async-tungstenite?/tokio-native-tls"]
42+
websocket = ["dep:async-tungstenite", "dep:tokio-util", "dep:futures-util", "dep:ws_stream_tungstenite"]
43+
websockets = ["websocket"]
4344
validate-tenant-prefix = []
4445
allow-duplicate-clientid = []
4546

rumqttd/rumqttd.toml

+27-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,33 @@ next_connection_delay_ms = 1
8282
listen = "127.0.0.1:9042"
8383
interval = 1
8484

85-
[ws]
85+
[ws.1]
86+
name = "ws-1"
87+
listen = "0.0.0.0:8083"
88+
next_connection_delay_ms = 1
89+
[ws.1.connections]
90+
connection_timeout_ms = 60000
91+
max_client_id_len = 256
92+
throttle_delay_ms = 0
93+
max_payload_size = 20480
94+
max_inflight_count = 500
95+
max_inflight_size = 1024
96+
97+
# [ws.2]
98+
# name = "ws-2"
99+
# listen = "0.0.0.0:8081"
100+
# next_connection_delay_ms = 1
101+
# [ws.2.tls]
102+
# capath = "/etc/tls/ca.cert.pem"
103+
# certpath = "/etc/tls/server.cert.pem"
104+
# keypath = "/etc/tls/server.key.pem"
105+
# [ws.2.connections]
106+
# connection_timeout_ms = 60000
107+
# max_client_id_len = 256
108+
# throttle_delay_ms = 0
109+
# max_payload_size = 20480
110+
# max_inflight_count = 500
111+
# max_inflight_size = 1024
86112

87113
[console]
88114
listen = "0.0.0.0:3030"

rumqttd/src/link/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ pub mod local;
55
pub mod meters;
66
pub mod network;
77
pub mod remote;
8-
#[cfg(feature = "websockets")]
9-
pub mod shadow;
108
pub mod timer;

rumqttd/src/link/network.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@ impl<P: Protocol> Network<P> {
142142
}
143143
}
144144

145-
pub trait N: AsyncRead + AsyncWrite + Send + Sync + Unpin {}
146-
impl<T> N for T where T: AsyncRead + AsyncWrite + Unpin + Send + Sync {}
145+
pub trait N: AsyncRead + AsyncWrite + Send + Unpin {}
146+
impl<T> N for T where T: AsyncRead + AsyncWrite + Unpin + Send {}

0 commit comments

Comments
 (0)