final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<String> result = new AtomicReference<String>();
webSocketChannel.getReceiveSetter().set(new ChannelListener<WebSocketChannel>() {
@Override
public void handleEvent(final WebSocketChannel channel) {
ChannelInputStream stream = null;
try {
final StreamSourceFrameChannel r = channel.receive();
if (r != null) {
stream = new ChannelInputStream(r);
result.set(FileUtils.readFile(stream));
latch.countDown();
}
} catch (IOException e) {
e.printStackTrace();