Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,23 @@ public static ConsoleProxyNoVncClient getNoVncViewer(ConsoleProxyClientParam par
!param.getClientHostPassword().equals(viewer.getClientHostPassword()))
throw new AuthenticationException("Cannot use the existing viewer " + viewer + ": bad sid");

if (!viewer.isFrontEndAlive()) {
try {
authenticationExternally(param);
viewer.initClient(param);
reportLoadChange = true;
} catch (Exception e) {
s_logger.error("Authencation failed for param: " + param);
return null;
}
s_logger.info("Initializing new novnc client and disconnecting existing session");
try {
((ConsoleProxyNoVncClient)viewer).getSession().disconnect();
} catch (IOException e) {
s_logger.error("Exception while disconnect session of novnc viewer object: " + viewer, e);
}
removeViewer(viewer);
viewer = new ConsoleProxyNoVncClient(session);
viewer.initClient(param);
connectionMap.put(clientKey, viewer);
reportLoadChange = true;
}

if (reportLoadChange) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@WebSocket
public class ConsoleProxyNoVNCHandler extends WebSocketHandler {

private ConsoleProxyNoVncClient viewer;
private ConsoleProxyNoVncClient viewer = null;
private static final Logger s_logger = Logger.getLogger(ConsoleProxyNoVNCHandler.class);

public ConsoleProxyNoVNCHandler() {
Expand Down Expand Up @@ -130,12 +130,18 @@ public void onConnect(final Session session) throws IOException, InterruptedExce
} catch (Exception e) {
s_logger.warn("Failed to create viewer due to " + e.getMessage(), e);
return;
} finally {
if (viewer == null) {
session.disconnect();
}
}
}

@OnWebSocketClose
public void onClose(Session session, int statusCode, String reason) throws IOException, InterruptedException {
ConsoleProxy.removeViewer(viewer);
if (viewer != null) {
ConsoleProxy.removeViewer(viewer);
}
}

@OnWebSocketFrame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,8 @@ public String getClientTag() {
return "";
}

public Session getSession() {
return session;
}

}