Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket connection to 'ws:https://localhost:1883/' failed: #9

Open
JamesArthurHolland opened this issue Dec 22, 2022 · 1 comment

Comments

@JamesArthurHolland
Copy link

I don't know why this is failing with the error:

WebSocket connection to 'ws:https://localhost:1883/' failed:

const protocol = "mqtt"
const host = "localhost"
const port = 1883

app.use(mqttVueHook, `${protocol}:https://${host}:${port}`, {
    clean: false,
    keepalive: 60,
    clientId: `mqtt_client_${Math.random().toString(16).substring(2, 10)}`,
    connectTimeout: 4000,
})

I can connect with the gui program MQTTLens no problem and subscribe to topics.

I've tried multiple different protocols, non seem to work. It shows as ws though even when I put mqtt or tcp.

The error reporting isn't really helpful. Is that from your lib or the underlying one?

@tommy44458
Copy link
Owner

Hi @JamesArthurHolland ,

Do you run your code in the browser? If yes, port 1883(mqtt:https://) is the default for native MQTT, not MQTT over websockets. Thus, your MQTT broker needs to listen websocket port(ws:https://) and be connected by it in the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants