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 return url
} }
@ -320,17 +324,16 @@ const setUpConsoleProxy = (webServer, xo) => {
return return
} }
const url = getVmConsoleUrl(xo, matches[1]) try {
if (!url) { const url = getVmConsoleUrl(xo, matches[1])
return
}
// FIXME: lost connection due to VM restart is not detected. // FIXME: lost connection due to VM restart is not detected.
webSocketServer.handleUpgrade(req, socket, head, connection => { webSocketServer.handleUpgrade(req, socket, head, connection => {
wsProxy(connection, url, { wsProxy(connection, url, {
rejectUnauthorized: false rejectUnauthorized: false
})
}) })
}) } catch (_) {}
}) })
} }