= Async HTTP Client (AHC) Websocket Component (deprecated)
:doctitle: Async HTTP Client (AHC) Websocket
:shortname: ahc-ws
:artifactid: camel-ahc-ws
:description: Exchange data with external Websocket servers using Async Http Client.
:since: 2.14
:supportlevel: Stable-deprecated
:deprecated: *deprecated*
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:camel-spring-boot-name: ahc-ws

*Since Camel {since}*

*{component-header}*

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 xref:ahc-component.adoc[AHC] component that in turn uses
the 
https://github.com/AsyncHttpClient/async-http-client[Async Http Client] 
library.

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

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-ahc-ws</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------

== URI Format

[source,java]
-------------------------------------------------
ahc-ws://hostname[:port][/resourceUri][?options]
ahc-wss://hostname[:port][/resourceUri][?options]
-------------------------------------------------

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


// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END


== 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.

[source,java]
-----------------------------------
from("direct:start")
        .to("ahc-ws://targethost");
-----------------------------------

And the equivalent Spring sample:

[source,xml]
------------------------------------------------------------
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:start"/>
    <to uri="ahc-ws://targethost"/>
  </route>
</camelContext>
------------------------------------------------------------

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

[source,java]
---------------------------
from("ahc-ws://targethost")
        .to("direct:next");
---------------------------

And the equivalent Spring sample:

[source,xml]
------------------------------------------------------------
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="ahc-ws://targethost"/>
    <to uri="direct:next"/>
  </route>
</camelContext>
------------------------------------------------------------

 



include::spring-boot:partial$starter.adoc[]
