Hello,

I will respond to myself.

It seems that websockets connection is created at the begining of all
javascript initialization. When the server receives the new

connection it inmediatly (in my implementation) sends a registration
request. This is not catched by the receiver because the javascript

is still initializing. So it's lost.

If I delay it a little bit, few seconds everything goes smoothly. Of
course I have to change this to let client tell when it's really ready
to start

the communication.

Thank you for help!



El 08/03/17 a las 18:30, Gonzalo Aguilar Delgado escribió:
> Hello,
>
>
> As I told still doing testing with the web sockets. It seems that a
> reconnection doesn't fully work. I don't know why.
>
> If the connection is the first the browser does. It works nice. The
> server sends a message to the client (browser) and the browser responds
> with a request for data.
>
> That works nicely.
>
> But when I reload the page, most of times doesn't work.
>
> 2017-03-08 18:19:14,117 [http-bio-8080-exec-29] DEBUG
> com.level2.dashboard.web.component.websocket.MessengerWebSocketResource
> - Connected application
> com.level2.dashboard.PandoraApplicationImpl@49b8641c with session id
> AAD6510DE8CA72C6CE7FF1FD4F1CF03D
> 2017-03-08 18:19:14,117 [http-bio-8080-exec-29] WARN 
> com.level2.dashboard.web.component.websocket.WebSocketClientManagerImpl
> - The client
> a13f637ea458fb61807e65429a9c18e3f5e8dd46cbe2d46cd1cc0894b4abb2f is
> already connected, resending id
>
> The server receives a connection. And in response it sends a message to
> the client with a client ID. The client should respond. but it seems
> browser never receives the message.
>
> Why it doesn't work? Can connection be dropped or messages lost?
>
> I added some logs to see if the socket is closed but it's ok.
>     @Override
>     public boolean sendMessage(ConnectionIdentifier identifier, String
> message)
>     {
>         Application application =
> Application.get(identifier.getApplicationName());
>         IWebSocketSettings webSocketSettings =
> IWebSocketSettings.Holder.get(application);
>         IWebSocketConnectionRegistry webSocketConnectionRegistry =
> webSocketSettings.getConnectionRegistry();
>         IWebSocketConnection connection =
> webSocketConnectionRegistry.getConnection(application,
> identifier.getSessionId(), identifier.getKey());
>         if (connection == null || !connection.isOpen())
>         {
>             log.warn("Connection is closed!!!");
>             return false;
>         }
>         try {
>             connection.sendMessage(message);
>         } catch (IOException e) {
>             log.warn("Cannot send message: {}", e.getMessage());
>             return false;
>         }
>         return true;
>     }
> So Why I cannot send it. Or why the client is not receiving it?
>
> Best regards,
>
>
>

Reply via email to