ARTEMIS-1160 AMQP test client should configure netty WS maxFrameSize

Need to configure the WS Handshaker in the test client's netty transport
with the same value given to the proton connection via setMaxFrameSize
so that incoming frames larger than the default 65535 over WS don't
trigger netty to fail the connection.
This commit is contained in:
Timothy Bish 2017-05-11 18:50:36 -04:00
parent ac97d6f057
commit e872f1524a
4 changed files with 25 additions and 5 deletions

View File

@ -109,9 +109,7 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
private boolean trace; private boolean trace;
private boolean noContainerID = false; private boolean noContainerID = false;
public AmqpConnection(org.apache.activemq.transport.amqp.client.transport.NettyTransport transport, public AmqpConnection(org.apache.activemq.transport.amqp.client.transport.NettyTransport transport, String username, String password) {
String username,
String password) {
setEndpoint(Connection.Factory.create()); setEndpoint(Connection.Factory.create());
getEndpoint().collect(protonCollector); getEndpoint().collect(protonCollector);
@ -137,6 +135,7 @@ public class AmqpConnection extends AmqpAbstractResource<Connection> implements
this.serializer.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); this.serializer.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
this.transport.setTransportListener(this); this.transport.setTransportListener(this);
this.transport.setMaxFrameSize(getMaxFrameSize());
} }
public void connect() throws Exception { public void connect() throws Exception {

View File

@ -55,6 +55,7 @@ public class NettyTcpTransport implements NettyTransport {
private static final Logger LOG = LoggerFactory.getLogger(NettyTcpTransport.class); private static final Logger LOG = LoggerFactory.getLogger(NettyTcpTransport.class);
private static final int SHUTDOWN_TIMEOUT = 100; private static final int SHUTDOWN_TIMEOUT = 100;
public static final int DEFAULT_MAX_FRAME_SIZE = 65535;
protected Bootstrap bootstrap; protected Bootstrap bootstrap;
protected EventLoopGroup group; protected EventLoopGroup group;
@ -62,6 +63,7 @@ public class NettyTcpTransport implements NettyTransport {
protected NettyTransportListener listener; protected NettyTransportListener listener;
protected final NettyTransportOptions options; protected final NettyTransportOptions options;
protected final URI remote; protected final URI remote;
protected int maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
private final AtomicBoolean connected = new AtomicBoolean(); private final AtomicBoolean connected = new AtomicBoolean();
private final AtomicBoolean closed = new AtomicBoolean(); private final AtomicBoolean closed = new AtomicBoolean();
@ -265,6 +267,20 @@ public class NettyTcpTransport implements NettyTransport {
return result; return result;
} }
@Override
public void setMaxFrameSize(int maxFrameSize) {
if (connected.get()) {
throw new IllegalStateException("Cannot change Max Frame Size while connected.");
}
this.maxFrameSize = maxFrameSize;
}
@Override
public int getMaxFrameSize() {
return maxFrameSize;
}
// ----- Internal implementation details, can be overridden as needed -----// // ----- Internal implementation details, can be overridden as needed -----//
protected String getRemoteHost() { protected String getRemoteHost() {

View File

@ -49,4 +49,8 @@ public interface NettyTransport {
Principal getLocalPrincipal(); Principal getLocalPrincipal();
void setMaxFrameSize(int maxFrameSize);
int getMaxFrameSize();
} }

View File

@ -113,8 +113,9 @@ public class NettyWSTransport extends NettyTcpTransport {
private final WebSocketClientHandshaker handshaker; private final WebSocketClientHandshaker handshaker;
NettyWebSocketTransportHandler() { NettyWebSocketTransportHandler() {
handshaker = WebSocketClientHandshakerFactory.newHandshaker(getRemoteLocation(), WebSocketVersion.V13, AMQP_SUB_PROTOCOL, true, handshaker = WebSocketClientHandshakerFactory.newHandshaker(
new DefaultHttpHeaders()); getRemoteLocation(), WebSocketVersion.V13, AMQP_SUB_PROTOCOL,
true, new DefaultHttpHeaders(), getMaxFrameSize());
} }
@Override @Override