tauri icon indicating copy to clipboard operation
tauri copied to clipboard

Not a bug. I can't connect to the mqtt broker from the Tauri + Vue application.

Open ulizkoigor opened this issue 1 year ago • 1 comments

Describe the bug

I can't connect to the mqtt broker. I use the library mqtt.js , it works with npm run dev, but when I'm doing an npm run build - it stops working. Maybe I'm doing something wrong? Please tell me the technology for connecting to the mqtt broker from the tauri + vue application.

Reproduction

No response

Expected behavior

No response

Full tauri info output

WARNING: Only one package manager should be used, but found npm and pnpm.
         Please remove unused package manager lock files, will use npm for now!

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 121.0.2277.106
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.11.0
    - pnpm: 8.15.1
    - npm: 9.8.1

[-] Packages
    - tauri [RUST]: 1.5.4
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.7
    - tao [RUST]: 0.16.7
    - @tauri-apps/api [NPM]: 1.5.3
    - @tauri-apps/cli [NPM]: 1.5.9

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

ulizkoigor avatar Feb 09 '24 18:02 ulizkoigor

Hi, can you try a debug build via npm run tauri build -- --debug (output in target/debug/)? It will behave like the release build but with the devtools enabled which means you can check the devtools console for errors (right click -> inspect).

In build mode tauri will serve your files over https://tauri.localhost (Linux/macos: tauri://localhost) instead of localhost:port so I'd assume this is causing issues here.

FabianLars avatar Feb 11 '24 13:02 FabianLars

Hi, can you try a debug build via npm run tauri build -- --debug (output in target/debug/)? It will behave like the release build but with the devtools enabled which means you can check the devtools console for errors (right click -> inspect).

In build mode tauri will serve your files over https://tauri.localhost (Linux/macos: tauri://localhost) instead of localhost:port so I'd assume this is causing issues here.

Hi! Thank you so much for your help! I did as you said and realized what the mistake was. In production, tauri does not work using the ws protocol, only wss. The tauri localhost plugin helped me (https://github.com/tauri-apps/plugins-workspace/tree/v1/plugins/localhost). Using it, my application can connect via the ws protocol. Thanks again.

ulizkoigor avatar Mar 06 '24 12:03 ulizkoigor