2 Home
gitea_admin edited this page 2026-03-11 14:43:00 +00:00

Vert.x WebSocket

Expose WebSocket endpoints and connect to remote WebSocket servers using Vert.x

Metadata

Property Value
Scheme vertx-websocket
Support Level Stable
Labels http,networking
Version 4.10.2

Maven Dependency

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-vertx-websocket</artifactId>
    <version>4.10.2</version>
</dependency>

Endpoint Properties

Name Type Required Default Description
host string WebSocket hostname, such as localhost or a remote host when in client mode.
port integer WebSocket port number to use.
path string WebSocket path to use.
allowedOriginPattern string Regex pattern to match the origin header sent by WebSocket clients
allowOriginHeader boolean true Whether the WebSocket client should add the Origin header to the WebSocket handshake request.
consumeAsClient boolean false When set to true, the consumer acts as a WebSocket client, creating exchanges on each received WebSocket event.
fireWebSocketConnectionEvents boolean false Whether the server consumer will create a message exchange when a new WebSocket peer connects or disconnects
handshakeHeaders object Headers to send in the HTTP handshake request. When the endpoint is a consumer, it only works when it consumes a remote host as a client (i.e. consumeAsClient is true).
maxReconnectAttempts integer 0 When consumeAsClient is set to true this sets the maximum number of allowed reconnection attempts to a previously closed WebSocket. A value of 0 (the default) will attempt to reconnect indefinitely.
originHeaderUrl string The value of the Origin header that the WebSocket client should use on the WebSocket handshake request. When not specified, the WebSocket client will automatically determine the value for the Origin from the request URL.
reconnectInitialDelay integer 0 When consumeAsClient is set to true this sets the initial delay in milliseconds before attempting to reconnect to a previously closed WebSocket.
reconnectInterval integer 1000 When consumeAsClient is set to true this sets the interval in milliseconds at which reconnecting to a previously closed WebSocket occurs.
router object To use an existing vertx router for the HTTP server
serverOptions object Sets customized options for configuring the HTTP server hosting the WebSocket for the consumer
bridgeErrorHandler boolean false Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.
exceptionHandler object To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.
exchangePattern object Sets the exchange pattern when the consumer creates an exchange.
clientOptions object Sets customized options for configuring the WebSocket client used in the producer
clientSubProtocols string Comma separated list of WebSocket subprotocols that the client should use for the Sec-WebSocket-Protocol header
sendToAll boolean false To send to all websocket subscribers. Can be used to configure at the endpoint level, instead of providing the VertxWebsocketConstants.SEND_TO_ALL header on the message. Note that when using this option, the host name specified for the vertx-websocket producer URI must match one used for an existing vertx-websocket consumer. Note that this option only applies when producing messages to endpoints hosted by the vertx-websocket consumer and not to an externally hosted WebSocket.
lazyStartProducer boolean false Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.
sslContextParameters object To configure security using SSLContextParameters