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

Why do I use mqtt protocol to connect, and finally become WS protocol #1488

Closed
zhong946555 opened this issue Jun 1, 2022 · 6 comments
Closed

Comments

@zhong946555
Copy link

image
image

@zhong946555
Copy link
Author

Can someone help me? I'm a novice. I've been fooled by this for two days

@kolboss
Copy link

kolboss commented Jun 2, 2022

Hi,
got the same problem

@doc-han
Copy link

doc-han commented Jun 9, 2022

MQTT is a protocol. A protocol is a set of pre-defined instructions computers use to communicate or understand each other when connected. So MQTT is just a language computers speak when connected. other examples of protocols are HTTP, HTTPS. These are mainly for resource sharing.

Now let's talk about the connection. Computers are able to connect with one another using the TCP/IP internet protocol.
So the simple way will be to have the IP of the other computer and then connect with it, After which you'll use another protocol to share resources.

For native use, we are able to use the TCP/IP on a computer(mostly called socket connections) but in the browser, we don't have access to that. Hence, we replace it with WebSockets with seems to work quit similar as that in the browser

@albertphlin
Copy link

In short, mqtt.js only use websockets whatever you set it to mqtt:// or ws://. So, you need to make sure the borker you want to connect has using websockets on that port.

@robertsLando
Copy link
Member

MQTT 5.0.0 BETA is now available! Try it out and give us feedback: npm i mqtt@beta. It may fix your issues

@robertsLando
Copy link
Member

I have fixed Browser docs by adding webpack and vite setup. Check them out

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

5 participants