title: Java websocket: How to receive PongMessage from websocket client and respond to this message
body: <p>I am trying to send PongMessage to a server from web-socket client (heart-beat message you may say).</p>
  
  <p>In server, I have written a method like this inside a class Annotated with <code>@ServerEndpoint</code> :</p>
  
  <pre><code>@OnMessage
          public void onPong(PongMessage pongMessage, Session session) {
  
            LOGGER.log(Level.INFO, " -- Got Hit Yaay!! -- ");
  
                  try {
                      session.getBasicRemote().sendText(PONG_RECEIVED);
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
  
          }
  </code></pre>
  
  <p>PongMessage Accepts <code>ByteBuffer</code> according to an oracle documentation. I tried generating a bytebuffer in server and sending exact same generated bytebuffer value from socket client. Server still throws an exception saying it <em>Cannot decode a string</em>.</p>
  
  <p>I am not able to hit <code>onPong() method</code>. Is there any format for <code>pongmessage</code> that client can send to a websocket server so that onPong() method gets invoked?  What am I doing wrong here? Any Ideas ?  </p>