Java implementation of an AJP13 protocol client, allowing to send requests to a servlet container using this protocol.
It uses netty, and handles connection pooling.
Licensed under the Apache License, Version 2.0 (see LICENSE)
import com.github.jrialland.ajpclient.pool.Channels;
import com.github.jrialland.ajpclient.CPing;
...
//get a tcp connection
final Channel channel = Channels.connect("localhost", 8009);
//will try a cping/cpong exchange on the opened tcp connection
boolean success = new CPing(2, TimeUnit.SECONDS).execute(channel);
// .execute("localhost", 8009);
import com.github.jrialland.ajpclient.pool.Channels;
import com.github.jrialland.ajpclient.Forward;
//send a forward request
new Forward(ajpRequest, ajpResponse).execute("localhost", 8009);
Socket pools handle the creation and destruction of multiple connections automatically.
import com.github.jrialland.ajpclient.pool.Channels;
import com.github.jrialland.ajpclient.Forward;
Channels.getPool("localhost", 8009).execute(new Forward(ajpRequest, ajpResponse));
Will use a socket channel picked from a pool, allowing the reuse of sockets among request.
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.github.jrialland.ajpclient.servlet.AjpServletProxy;
HttpServletRequest request = ...
HttpServetResponse response = ...
//forward an servlet request to another server
AjpServletProxy.forHost("localhost", 8009).forward(request, response);
The protocol does not allow request headers to be greater that 8K, which is ok most of the time. You should avoid to pass more that 8k of headers, but if you do, to overcome this limit, at least with tomcat 5.5.21+ and Tomcat 6.0.1+
1) add the packetSize
attribute to the connector's declaration
<Connector port="8009" protocol="AJP/1.3"
packetSize="20000"
redirectPort="8443" ></Connector>
2) Change the limit in Apache Server configuration :
ProxyIOBufferSize 19000
LimitRequestFieldsize 18000