Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try with <code>TruncatedChannelBuffer</code> or <code>BigEndianHeapChannelBuffer</code> instead of channelbuffer in your <code>ClientHandler</code>. I think it will work.. or if it doesn't work, kindly post stacktrace of generated exception. I tried this in my code and it worked..I hope this will help you.</p> <pre><code>public void messageReceived(ChannelHandlerContext channelHandlerContext,MessageEvent messageEvent) throws Exception { Object messageObject = messageEvent.getMessage(); // if size of message &lt; 1024 then TruncatedChannelBuffer is returned. if (messageObject instanceof TruncatedChannelBuffer) { try { TruncatedChannelBuffer truncatedChannelBuffer = (TruncatedChannelBuffer) messageObject; byte[] byteArray = new byte[truncatedChannelBuffer.readableBytes()]; truncatedChannelBuffer.readBytes(byteArray); System.out.print(" Message = "+new String(byteArray)); truncatedChannelBuffer.clear(); } catch (Exception e) { System.out.println("Exception in MessageReceived..."); e.printStackTrace(); } } // if size of message &gt; 1024 then BigEndianHeapChannelBuffer is returned. if (messageObject instanceof BigEndianHeapChannelBuffer) { try { BigEndianHeapChannelBuffer bigEndianHeapChannelBuffer = (BigEndianHeapChannelBuffer) messageObject; byte[] byteArray = new byte[bigEndianHeapChannelBuffer.readableBytes()]; bigEndianHeapChannelBuffer.readBytes(byteArray); System.out.print(" Message = "+new String(byteArray)); bigEndianHeapChannelBuffer.clear(); } catch (Exception e) { System.out.println("Exception in MessageReceived..."); e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload