Re: WebSocket - Client doesn't receive server messages

2017-05-23 Thread Simon De Uvarow
To add some info, I implemented a client for browsers (HTML + javascript
client) and it's working properly. I'm receiving the messages from the
server as expected.
So, the problem is in the JAVA test, not the server.


"No olvides, no traiciones, lo que llevas bien dentro de ti. No olvides, no
traiciones, lo que siempre te ha hecho vivir."

On Mon, May 22, 2017 at 9:52 PM, Simon De Uvarow 
wrote:

> Hi, I'm having a strange issue:
>
> I'm developing a frontend with WebSockets, (my first WebSocket! ). To test
> the code I'm also developing some tests to run in Eclipse.
>
> So, I create a Client in the Test, connect to the server, and want to have
> some communication.
> I added lot of logs to debug the issue:
>
> - *WebsocketClientEndpoint*:33 - Connect to server
> - *WebsocketClientEndpoint*:41 - Before Request: Cookie, JSESSIONID=
> A65A4F5711DC8820C246DDD45A409BFA
> - WebSocketFilter:38 - Filter executing ..
> - *WebsocketClientEndpoint*:64 - opening websocket
> - WebSocketServer:59 - 1 has opened a connection
> - WebSocketServer:64 - clientIP: 127.0.0.1
> - *WebsocketClientEndpoin*t:113 - sendMessage 
> - WebSocketServer:75 - onMessage: .
> - WebSocketServer:117 - Send OK message
>
> At the end, the server sends a response ("OK"), and the client waits for
> the response of the server.
> But the client doesn't receive it, no mater how long I wait.
> I debug the Tomcats code, but couldn't find the issue.
> It's not clear for me the point where the library writes the information
> in the socket.
>
> This is how I send the response from the server:
>
> *WFMWebSocketServer*
>
>   * @OnMessage*
>public void onMessage(String message) {
>   ..
>  // Send OK response
>  try {
> logger.debug("Send OK message");
> *session.getBasicRemote().sendText("OK");*
>  } catch (IOException e) {
> e.printStackTrace();
>  }
>  .
>}
>
> The following is the @OnOpen code:
>
>*@OnOpen*
>public void onOpen(Session session) {
>
>   this.session = session;
>   logger.info(session.getId() + " has opened a connection");
>   final PrincipalWithRemoteAddress pws = ((PrincipalWithRemoteAddress)
> session.getUserPrincipal());
>   remoteAdr = pws == null ? null : pws.getRemoteAdr();
>
>   try {
> * session.getBasicRemote().sendText("OK");*
>   } catch (IOException e) {
>  e.printStackTrace();
>   }
>}
>
> Also the previous "OK" message is not received in the client, I don't see
> the log of it in the console:
>
>
> *WebsocketClientEndpoint*
>@OnMessage
>public void onMessage(String message) {
>   logger.debug("onMessage: " + message);
>
>   if (this.messageHandler != null) {
>  this.messageHandler.handleMessage(message);
>   }
>}
>
>
> Any idea why I am having just like half duplex communication ?
> Or any idea how to debug or analyze the issue in order to fix it?
>
> The version of the libraries and Tomcat I'm using is:
> 8.5.15
>
> Thanks!
>
>
> "No olvides, no traiciones, lo que llevas bien dentro de ti. No olvides,
> no traiciones, lo que siempre te ha hecho vivir."
>


WebSocket - Client doesn't receive server messages

2017-05-22 Thread Simon De Uvarow
Hi, I'm having a strange issue:

I'm developing a frontend with WebSockets, (my first WebSocket! ). To test
the code I'm also developing some tests to run in Eclipse.

So, I create a Client in the Test, connect to the server, and want to have
some communication.
I added lot of logs to debug the issue:

- *WebsocketClientEndpoint*:33 - Connect to server
- *WebsocketClientEndpoint*:41 - Before Request: Cookie,
JSESSIONID=A65A4F5711DC8820C246DDD45A409BFA
- WebSocketFilter:38 - Filter executing ..
- *WebsocketClientEndpoint*:64 - opening websocket
- WebSocketServer:59 - 1 has opened a connection
- WebSocketServer:64 - clientIP: 127.0.0.1
- *WebsocketClientEndpoin*t:113 - sendMessage 
- WebSocketServer:75 - onMessage: .
- WebSocketServer:117 - Send OK message

At the end, the server sends a response ("OK"), and the client waits for
the response of the server.
But the client doesn't receive it, no mater how long I wait.
I debug the Tomcats code, but couldn't find the issue.
It's not clear for me the point where the library writes the information in
the socket.

This is how I send the response from the server:

*WFMWebSocketServer*

  * @OnMessage*
   public void onMessage(String message) {
  ..
 // Send OK response
 try {
logger.debug("Send OK message");
*session.getBasicRemote().sendText("OK");*
 } catch (IOException e) {
e.printStackTrace();
 }
 .
   }

The following is the @OnOpen code:

   *@OnOpen*
   public void onOpen(Session session) {

  this.session = session;
  logger.info(session.getId() + " has opened a connection");
  final PrincipalWithRemoteAddress pws = ((PrincipalWithRemoteAddress)
session.getUserPrincipal());
  remoteAdr = pws == null ? null : pws.getRemoteAdr();

  try {
* session.getBasicRemote().sendText("OK");*
  } catch (IOException e) {
 e.printStackTrace();
  }
   }

Also the previous "OK" message is not received in the client, I don't see
the log of it in the console:


*WebsocketClientEndpoint*
   @OnMessage
   public void onMessage(String message) {
  logger.debug("onMessage: " + message);

  if (this.messageHandler != null) {
 this.messageHandler.handleMessage(message);
  }
   }


Any idea why I am having just like half duplex communication ?
Or any idea how to debug or analyze the issue in order to fix it?

The version of the libraries and Tomcat I'm using is:
8.5.15

Thanks!


"No olvides, no traiciones, lo que llevas bien dentro de ti. No olvides, no
traiciones, lo que siempre te ha hecho vivir."