Bluetooth requestDevice() is undefined on Amazon Lightsail










1















The following example (1) lists available Bluetooth devices when opened as a file in Chrome version 70.



When uploading the same exact example to an Amazon Ligtsail instance I get the following error message:



Uncaught TypeError: Cannot read property 'requestDevice' of undefined
at connect ((index):9)
at HTMLButtonElement.onclick ((index):4)


Can anyone explain to me what the issue might be? Since this is JavaScript, it should be executed in the browser and be unrelated to any server setup?



.



(1) Example code that generates the error on Amazon Lightsail



<html>
<body>
<button onclick="connect();">Click here</button>
<script>
function connect()
console.log('Getting Bluetooth Device...');
navigator.bluetooth.requestDevice(

acceptAllDevices : true
)
.then(device =>
console.log('Got device');
)
.catch(error =>
console.log(error);
);

</script>
</body>
</html>









share|improve this question



















  • 1





    What happens if you access via an HTTPS endpoint?

    – kdgregory
    Nov 15 '18 at 15:48















1















The following example (1) lists available Bluetooth devices when opened as a file in Chrome version 70.



When uploading the same exact example to an Amazon Ligtsail instance I get the following error message:



Uncaught TypeError: Cannot read property 'requestDevice' of undefined
at connect ((index):9)
at HTMLButtonElement.onclick ((index):4)


Can anyone explain to me what the issue might be? Since this is JavaScript, it should be executed in the browser and be unrelated to any server setup?



.



(1) Example code that generates the error on Amazon Lightsail



<html>
<body>
<button onclick="connect();">Click here</button>
<script>
function connect()
console.log('Getting Bluetooth Device...');
navigator.bluetooth.requestDevice(

acceptAllDevices : true
)
.then(device =>
console.log('Got device');
)
.catch(error =>
console.log(error);
);

</script>
</body>
</html>









share|improve this question



















  • 1





    What happens if you access via an HTTPS endpoint?

    – kdgregory
    Nov 15 '18 at 15:48













1












1








1








The following example (1) lists available Bluetooth devices when opened as a file in Chrome version 70.



When uploading the same exact example to an Amazon Ligtsail instance I get the following error message:



Uncaught TypeError: Cannot read property 'requestDevice' of undefined
at connect ((index):9)
at HTMLButtonElement.onclick ((index):4)


Can anyone explain to me what the issue might be? Since this is JavaScript, it should be executed in the browser and be unrelated to any server setup?



.



(1) Example code that generates the error on Amazon Lightsail



<html>
<body>
<button onclick="connect();">Click here</button>
<script>
function connect()
console.log('Getting Bluetooth Device...');
navigator.bluetooth.requestDevice(

acceptAllDevices : true
)
.then(device =>
console.log('Got device');
)
.catch(error =>
console.log(error);
);

</script>
</body>
</html>









share|improve this question
















The following example (1) lists available Bluetooth devices when opened as a file in Chrome version 70.



When uploading the same exact example to an Amazon Ligtsail instance I get the following error message:



Uncaught TypeError: Cannot read property 'requestDevice' of undefined
at connect ((index):9)
at HTMLButtonElement.onclick ((index):4)


Can anyone explain to me what the issue might be? Since this is JavaScript, it should be executed in the browser and be unrelated to any server setup?



.



(1) Example code that generates the error on Amazon Lightsail



<html>
<body>
<button onclick="connect();">Click here</button>
<script>
function connect()
console.log('Getting Bluetooth Device...');
navigator.bluetooth.requestDevice(

acceptAllDevices : true
)
.then(device =>
console.log('Got device');
)
.catch(error =>
console.log(error);
);

</script>
</body>
</html>






amazon-web-services bluetooth web-bluetooth






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 16:20







Attaque

















asked Nov 15 '18 at 15:00









AttaqueAttaque

98111333




98111333







  • 1





    What happens if you access via an HTTPS endpoint?

    – kdgregory
    Nov 15 '18 at 15:48












  • 1





    What happens if you access via an HTTPS endpoint?

    – kdgregory
    Nov 15 '18 at 15:48







1




1





What happens if you access via an HTTPS endpoint?

– kdgregory
Nov 15 '18 at 15:48





What happens if you access via an HTTPS endpoint?

– kdgregory
Nov 15 '18 at 15:48












1 Answer
1






active

oldest

votes


















2














As @kdgregory suggested, the navigator.bluetooth is HTTPS only:




Because this experimental API is a powerful new feature added to the Web, Google Chrome aims to make it available only to secure contexts. This means you'll need to build with TLS in mind.




I added a GitHub pages and it works.



enter image description here






share|improve this answer

























  • I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

    – kdgregory
    Nov 16 '18 at 10:47










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322243%2fbluetooth-requestdevice-is-undefined-on-amazon-lightsail%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














As @kdgregory suggested, the navigator.bluetooth is HTTPS only:




Because this experimental API is a powerful new feature added to the Web, Google Chrome aims to make it available only to secure contexts. This means you'll need to build with TLS in mind.




I added a GitHub pages and it works.



enter image description here






share|improve this answer

























  • I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

    – kdgregory
    Nov 16 '18 at 10:47















2














As @kdgregory suggested, the navigator.bluetooth is HTTPS only:




Because this experimental API is a powerful new feature added to the Web, Google Chrome aims to make it available only to secure contexts. This means you'll need to build with TLS in mind.




I added a GitHub pages and it works.



enter image description here






share|improve this answer

























  • I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

    – kdgregory
    Nov 16 '18 at 10:47













2












2








2







As @kdgregory suggested, the navigator.bluetooth is HTTPS only:




Because this experimental API is a powerful new feature added to the Web, Google Chrome aims to make it available only to secure contexts. This means you'll need to build with TLS in mind.




I added a GitHub pages and it works.



enter image description here






share|improve this answer















As @kdgregory suggested, the navigator.bluetooth is HTTPS only:




Because this experimental API is a powerful new feature added to the Web, Google Chrome aims to make it available only to secure contexts. This means you'll need to build with TLS in mind.




I added a GitHub pages and it works.



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 17 '18 at 13:37

























answered Nov 15 '18 at 16:06









AttaqueAttaque

98111333




98111333












  • I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

    – kdgregory
    Nov 16 '18 at 10:47

















  • I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

    – kdgregory
    Nov 16 '18 at 10:47
















I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

– kdgregory
Nov 16 '18 at 10:47





I thought that might be the problem but didn't have the time to look. Glad to see that you were able to solve it, and write a good answer explaining it.

– kdgregory
Nov 16 '18 at 10:47



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322243%2fbluetooth-requestdevice-is-undefined-on-amazon-lightsail%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党