Do not crash when the console URL cannot be found.

This commit is contained in:
Julien Fontanet 2015-05-24 16:51:51 +02:00
parent 22ed022787
commit 5801b29ede

View File

@ -304,6 +304,10 @@ const getVmConsoleUrl = (xo, id) => {
}
})
if (!url) {
throw new Error('VM console not found')
}
return url
}
@ -320,17 +324,16 @@ const setUpConsoleProxy = (webServer, xo) => {
return
}
const url = getVmConsoleUrl(xo, matches[1])
if (!url) {
return
}
try {
const url = getVmConsoleUrl(xo, matches[1])
// FIXME: lost connection due to VM restart is not detected.
webSocketServer.handleUpgrade(req, socket, head, connection => {
wsProxy(connection, url, {
rejectUnauthorized: false
// FIXME: lost connection due to VM restart is not detected.
webSocketServer.handleUpgrade(req, socket, head, connection => {
wsProxy(connection, url, {
rejectUnauthorized: false
})
})
})
} catch (_) {}
})
}