Use plain HTTP as fallback when WSS fails
This commit is contained in:
parent
84ba14ef7c
commit
a45e2bd379
1 changed files with 20 additions and 1 deletions
21
index.html
21
index.html
|
@ -345,7 +345,26 @@ __ __ _ __ ____ __
|
|||
switch (device_type)
|
||||
{
|
||||
case "cloud":
|
||||
blockDevice = await CheerpX.CloudDevice.create(image_url);
|
||||
try
|
||||
{
|
||||
blockDevice = await CheerpX.CloudDevice.create(image_url);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
// Report the failure and try again with plain HTTP
|
||||
var wssProtocol = "wss:";
|
||||
if(image_url.startsWith(wssProtocol))
|
||||
{
|
||||
// WebSocket protocol failed, try agin using plain HTTP
|
||||
image_url = "https:" + image_url.substr(wssProtocol.length);
|
||||
blockDevice = await CheerpX.CloudDevice.create(image_url);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No other recovery option
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "bytes":
|
||||
blockDevice = await CheerpX.HttpBytesDevice.create(image_url);
|
||||
|
|
Loading…
Add table
Reference in a new issue