Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.

Async Http Client (AHC) Websocket Client Component

Available as of Camel 2.14

The ahc-ws component provides Websocket based endpoints for a client communicating with external servers over Websocket (as a client opening a websocket connection to an external server).
The component uses the AHC component that in turn uses the Async Http Client library.

Maven users will need to add the following dependency to their pom.xml for this component:

    <!-- use the same version as your Camel core version -->

URI Format


Will by default use port 80 for ahc-ws and 443 for ahc-wss.

AHC-WS Options

As the AHC-WS component is based on the AHC component, you can use the various configuration options of the AHC component.

In additon there are these options

useStreamingfalseProducer. To enable streaming to send data as multiple text fragments.
sendMessageOnErrorfalseCamel 2.17: Consumer. Whether to send an message if the web-socket listener received an error.


Writing and Reading Data over Websocket

An ahc-ws endpoint can either write data to the socket or read from the socket, depending on whether the endpoint is configured as the producer or the consumer, respectively.

Configuring URI to Write or Read Data

In the route below, Camel will write to the specified websocket connection.


And the equivalent Spring sample:

<camelContext xmlns="">
    <from uri="direct:start"/>
    <to uri="ahc-ws://targethost"/>

In the route below, Camel will read from the specified websocket connection.


And the equivalent Spring sample:

<camelContext xmlns="">
    <from uri="ahc-ws://targethost"/>
    <to uri="direct:next"/>


© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram