WebSocket connection error in the web

I am currently using a free version of HiveMQ and trying to integrate MQTT in the React Native project.

There is a doc on JavaScript integration in “Getting Started” section and followed the tutorial.
This code snippet is a setup according to tutorial:
var options = {
host: ‘myHostName’,
port: 8883,
protocol: ‘mqtts’,
username: ‘myUserName’,
password: ‘myPassword’

After I integrated, the web console gives an error message:“WebSocket connection to ‘wss://localhost:8883/’ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED”

Does anyone know how to solve this issue?

Hi @sback2063 ,
It is nice that you are interested in MQTT and HiveMQ, welcome to the community!

You indicated that the example does not work with your local broker – wss://localhost:8883/. Please confirm if the example works with your HiveMQ Cloud cluster or you see the same error.

If the code works with HiveMQ Cloud cluster and does not work with your local one, it might indicate that the local broker has configuration issues.

Kind regards,
Dasha from HiveMQ