Use plain HTTP as fallback when WSS fails
This commit is contained in:
parent
84ba14ef7c
commit
a45e2bd379
19
index.html
19
index.html
@ -345,7 +345,26 @@ __ __ _ __ ____ __
|
|||||||
switch (device_type)
|
switch (device_type)
|
||||||
{
|
{
|
||||||
case "cloud":
|
case "cloud":
|
||||||
|
try
|
||||||
|
{
|
||||||
blockDevice = await CheerpX.CloudDevice.create(image_url);
|
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;
|
break;
|
||||||
case "bytes":
|
case "bytes":
|
||||||
blockDevice = await CheerpX.HttpBytesDevice.create(image_url);
|
blockDevice = await CheerpX.HttpBytesDevice.create(image_url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user