Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/26442_websocket_server_shutdown.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix the `websocket_server` sink leaving its listener and client connections running after shutdown, which could prevent the port from being reused during configuration reloads.

authors: U-S-jun
24 changes: 23 additions & 1 deletion src/sinks/websocket_server/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{buffering::MessageBufferingConfig, sink::WebSocketListenerSink};
use crate::{
codecs::{EncodingConfig, Transformer},
common::http::server_auth::HttpServerAuthConfig,
config::{AcknowledgementsConfig, Input, SinkConfig, SinkContext, ValidatedSink},
config::{AcknowledgementsConfig, Input, Resource, SinkConfig, SinkContext, ValidatedSink},
sinks::{Healthcheck, VectorSink},
tls::{MaybeTlsSettings, TlsEnableableConfig},
};
Expand Down Expand Up @@ -138,6 +138,10 @@ impl SinkConfig for WebSocketListenerSinkConfig {
Input::new(self.encoding.config().input_type())
}

fn resources(&self) -> Vec<Resource> {
vec![Resource::tcp(self.address)]
}

fn acknowledgements(&self) -> &AcknowledgementsConfig {
&self.acknowledgements
}
Expand Down Expand Up @@ -212,6 +216,24 @@ mod test {
crate::test_util::test_generate_config::<WebSocketListenerSinkConfig>();
}

#[test]
fn reject_conflicting_listeners() {
let mut config = crate::config::Config::builder();
config.add_source("in", crate::test_util::mock::basic_source().1);
config.add_sink("first", &["in"], WebSocketListenerSinkConfig::default());
config.add_sink("second", &["in"], WebSocketListenerSinkConfig::default());

let errors = config
.build()
.expect_err("listeners cannot share a TCP port");
assert!(
errors
.iter()
.any(|error| error.contains("is claimed by multiple components")),
"{errors:?}"
);
}

#[test]
fn validate_produces_usable_state() {
let config = WebSocketListenerSinkConfig {
Expand Down
Loading
Loading