Problems with connecting noVNC to websocket

haimian

New Member
Jun 18, 2025
2
0
1
r.GET("/console", func(c *gin.Context) {
// Call the Proxmox API to get the console ticket
console, err := PveClient.GetVMConsole("pve", 1005)
if err != nil {
c.JSON(500, gin.H{"error": "Failed to get console"})
fmt.Printf("Failed to get console: %v\n", err)
return
}

// Constructing a redirect URL
vncPath := fmt.Sprintf(
"wss://%s:8006/nodes/%s/qemu/%d/vncwebsocket?port=%s&vncticket=%s",
"pve.bbccaa.org",
"pve",
100,
console.Port,
url.QueryEscape(console.Ticket),
)
fmt.Printf("VNC Path: %s\n", vncPath)
fullURL := "/novnc/vnc.html?autoconnect=true&path=" + url.QueryEscape(vncPath)
c.Redirect(http.StatusFound, fullURL)
})

I have obtained all the parameters normally, but my noVNC still cannot connect, and the websocket returns a 1006 error

rfb.js:968 Failed when connecting: Connection closed (code: 1006)

wss://pve.aaccbb.org:8006/nodes/pve/qemu/100/vncwebsocket?port=5900&vncticket=PVEVNC%3A685232CC%3A%3Ai4nbAWJipbyRJ92L4MClZBnRcLVvqwodPs4GD1MemqCAIMbmSFP1UV%2B5RyoTgpFniQ1%2BMEEGrBUGGegFd35bxZiW0rjyAHyVZKUlRbQ3nU6ORTcNKAs0G%2Byec99zR%2F%2B5rQluoRkEvmXxbbVpVA7lmUdFGBRFcFhzbYQDHK6gk2z42SiMlRZSVLxbhSc4hsF8f8aFN%2Fd0l23kO2kWqBsIViT4QIu5TV5shNuARNNGZ8kyGTzqvGk7l6ZbOUlpx2XnB98sQI4CsVF0krCa6NvrWMH52lObuzpEtnzQJytzMvH97gttOzcIL4HSMl3ERPfpI0h8s5HlKBQDaUGSXnJtiA%3D%3D1750218671894.png

My domain name certificate is valid, and the port test using telnet is also passed.
root@pve:~# ss -lntp |grep 5900
LISTEN 0 1 0.0.0.0:5900 0.0.0.0:* users:(("task UPID:pve:0",pid=95139,fd=6))
It is also normal. I don't know why I can't connect. How can I solve it?
 
i'm not super clear what exactly you are trying to do. Are you trying to connet via your own novnc installation? if yes, did you also set a valid cookie in the browser for the connection?
the websocket connection needs a valid cookie set + the vncticket
 
我不太清楚你到底想做什么。你是想通过你自己安装的 NovNC 连接吗?如果是,你在浏览器中设置了有效的 Cookie 来连接吗?
WebSocket 连接需要有效的 Cookie 集 + Vncticket
Yes, I want to connect through NovNC that I installed myself. I successfully connected to noVNC through the proxy, but the login page asked me to enter a password. Is this because there is something wrong with the data and cookies I passed in?
1750299273210.png