Skip to content

Commit

Permalink
Determine Push transport before re-connect
Browse files Browse the repository at this point in the history
onConnect was allways called with websocket = false. I think this is wrong, since if there was connection loss in websocket, now connection cannot be re-established in websocket mode.

Fixes: #11299

This bug may have been manifesting in other ways as well

Recently similar fix was done in Flow as well, see: vaadin/flow#7489
  • Loading branch information
TatuLund authored Feb 5, 2020
1 parent ab3d346 commit 958aa90
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,14 @@ protected void suspend(AtmosphereResource resource) {
* request)
*/
private void callWithUi(final AtmosphereResource resource,
final PushEventCallback callback, boolean websocket) {
final PushEventCallback callback) {
AtmosphereRequest req = resource.getRequest();
VaadinServletRequest vaadinRequest = new VaadinServletRequest(req,
service);
VaadinSession session = null;

if (websocket) {
boolean isWebsocket = resource.transport() == TRANSPORT.WEBSOCKET;
if (isWebSocket) {
// For any HTTP request we have already started the request in the
// servlet
service.requestStart(vaadinRequest, null);
Expand Down Expand Up @@ -281,7 +282,7 @@ private void callWithUi(final AtmosphereResource resource,
}
} finally {
try {
if (websocket) {
if (isWebSocket) {
service.requestEnd(vaadinRequest, null, session);
}
} catch (Exception e) {
Expand Down Expand Up @@ -520,7 +521,7 @@ private static boolean isPushIdValid(VaadinSession session,
* The related atmosphere resources
*/
void onConnect(AtmosphereResource resource) {
callWithUi(resource, establishCallback, false);
callWithUi(resource, establishCallback);
}

/**
Expand All @@ -531,8 +532,7 @@ void onConnect(AtmosphereResource resource) {
* The related atmosphere resources
*/
void onMessage(AtmosphereResource resource) {
callWithUi(resource, receiveCallback,
resource.transport() == TRANSPORT.WEBSOCKET);
callWithUi(resource, receiveCallback);
}

/**
Expand Down

0 comments on commit 958aa90

Please sign in to comment.