http – What makes MQTT a raw tcp connection that we can't run it in the browser? – Stack Overflow
All of HTTP, MQTT, Websockets use TCP directly (HTTP/3 uses UDP), which what you describe as a “raw” connection. But these are different application level protocols on top of TCP. For security reasons a browser does not allow “raw” TCP connections from within an web application. Instead it restricts what application protocol can be used. Anything else must be somehow translated into an allowed application protocol, for example tunneled over WebSockets instead of using “raw” TCP directly.
… but we can use websockets to transfer MQTT messages
Only if there is a backend which can translate the MQTT encapsulated in WebSockets into plain MQTT, i.e. remove the outer WebSockets tunnel.
Read more here: Source link
