wails icon indicating copy to clipboard operation
wails copied to clipboard

I tried to use WebSocket in Vue and found it unsuccessful

Open LunckyB opened this issue 2 years ago • 7 comments

I tried to use WebSocket in Vue and found it unsuccessful, Does Wails not support it? 1648531685(1)

LunckyB avatar Mar 29 '22 05:03 LunckyB

I believe it's the same issue as Tauri and Wails: websockets is only allows from a https source. Therefore, you can't use the ws:// designation. It's an issue with the built in browser for the operating system that Wails makes use of. I think the best solution is to create the functionality in the application go code and use signals to alert the front-end.

raguay avatar Mar 29 '22 06:03 raguay

I believe it's the same issue as Tauri and Wails: websockets is only allows from a https source. Therefore, you can't use the ws:// designation. It's an issue with the built in browser for the operating system that Wails makes use of. I think the best solution is to create the functionality in the application go code and use signals to alert the front-end.

Thank you for your reply. I now use Gorilla/Websocket in Wails

LunckyB avatar Mar 29 '22 08:03 LunckyB

I strongly recommend that the front-end part is only used to display UI, js is only used to handle front-end interaction logic and call Go, other business logic and communication should be done by Go, otherwise it will make the Wails application look like a shell, but in fact It can do more than that.

misitebao avatar Mar 29 '22 09:03 misitebao

☝️ This is the recommended best practice.

leaanthony avatar Mar 29 '22 10:03 leaanthony

Especially when the logical part is in Go, interactive response in the GUI is often necessary. WebSockets is default for such channels. But because it's way simpler, I personally switched to server-sent events for such topics. It has limitations compared to WebSockets, but works very well for some event transfer.

TheFranconianCoder avatar Apr 01 '22 09:04 TheFranconianCoder

I'm also developing 'webssh' recently, which just solves this problem vue3: const webSocket = new WebSocket(WebSocketAddr)

go:"github.com/gorilla/websocket"

PungYoung avatar Apr 18 '22 15:04 PungYoung

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 14:07 stale[bot]

Sounds like there's a workaround. Closing.

leaanthony avatar Nov 25 '22 03:11 leaanthony