Newbie: WebSocket anwers only one UI

Hi,

TBH, I am not quite sure how to describe the problem the best way to make it understandable. I’ll try my very best :slight_smile:

I made an application using Vaadin7 and springframework.web.socket.
When I send a message to my websocket-server it looks like the requests are coming from the correct session/UI.
The answers are received by the correct instance of the websocket-class but all of a sudden the UI is another one.
(MainUI and WebSocket-Class have a random “serial” I give them when initiated.)

  • Open two browsers
  • Browser 1: send message to websocket

SENDING FOR [StandardWebSocketSession[id=1, uri=null] ] UI 1532251341, socketclass serial is 1532251341 VAADIN SESSION 425EF973F0639AFF32BEAEBC8AD5FA81 - Socket Server says:

server received: {"session":"425EF973F0639AFF32BEAEBC8AD5FA81","..."} handle ([LoginRequest@47e76c10, StandardWebSocketSession[id=0, uri=/endpoint] ]) So it looks like everything is fine. The websocket-session-id on client-side is 1, server is 0, vaadin session is 6E58A33EA3264BE576FBAC329E546D0F and UI/socketclass-serial are the same.

  • Browser 2: send message to websocket

SENDING FOR [StandardWebSocketSession[id=3, uri=null] ] UI -1745168599, socketclass serial is -1745168599 VAADIN SESSION 794EC804CCB2A0C41FDA786B487B5A89 - Socket Server says:

server received: {"session":"794EC804CCB2A0C41FDA786B487B5A89","..."}
handle ([LoginRequest@47e76c10, StandardWebSocketSession[id=1, uri=/endpoint]
])

Still OK, client websocket-session-id is 3, server is 1, vaadin session is 794EC804CCB2A0C41FDA786B487B5A89 and UI/socketclass-serial are the same.

The next answer(s) from websocket-server:
For first call everything seems fine:

RECEIVED FOR [StandardWebSocketSession[id=1, uri=null] ] UI 1532251341, socketclass serial is 1532251341 VAADIN SESSION 425EF973F0639AFF32BEAEBC8AD5FA81 and second call

RECEIVED FOR [StandardWebSocketSession[id=3, uri=null]
] UI 1532251341,
socketclass serial is -1745168599 VAADIN SESSION 425EF973F0639AFF32BEAEBC8AD5FA81

All of a sudden, UI is 1532251341 although the socket-class-serial is from the second browser?

Additional informations:

  • No Autowire/other Spring-Related stuff
  • No statics
    WebSocket is initiated:
@Push public class MainUI extends UI {
public Integer serial = new Random().nextInt();
private Navigator navigator;
private WebSocketClientHandler webSocketClient;
public Integer getSerial() { return serial; }
public static MainUI getCurrent() { return (MainUI) UI.getCurrent(); }
@Override public void init(VaadinRequest vaadinRequest) {
Logger.getLogger(getClass().getName()).info("CREATED UI WITH SERIAL " + this.getSerial());
webSocketClient = new WebSocketClientHandler(this.getSerial());
new WebSocketConnectionManager(new StandardWebSocketClient(), webSocketClient, "ws://localhost:9090/endpoint").start();

Any idea what could cause the client-application to bind the websockets all to one UI ?
It looks like the answer from the server is received by the correct instance of websocket-client class but the UI is wrong.

I am pretty sure it’s some beginner-head@table-failure and it would be great, if you could clear this up to me :slight_smile: Thanks in advance.