admin管理员组文章数量:1123697
I'm using obs-websocket-js in a Tampermonkey userscript. This is more or less how it's defined, as minimal reproducible example:
let webSocketUrl = 'wss://link.to.ngrok.free.endpoint';
let websocketPassword = 'something';
const obs = new OBSWebSocket();
await connectToOBS();
async function connectToOBS() {
try {
await obs.connect(webSocketURL, webSocketPassword);
} catch (error) {
console.error(`Failed to connect to OBS: ${error.message || error.code}`);
}
}
With that code I had 1006
errors quite often when refreshing a page with the script or going back in history. My reconnection mechanism also couldn't reconnect. So I expected the problem to be with hanging sessions, which OBS terminates too late and causes some connection conflicts. It turned out to be right as adding:
window.addEventListener('beforeunload', async () => {
await obs.disconnect;
});
to the script almost got rid of the error. The problem is that it still appears very rarely.
What could other possible causes be? I suspected the disconnect erroring, but when debugging that it always closed the connection successfully. Any other ideas?
One more note is that there's nothing listen in the OBS websocket window when the fails happen, which would indicate there's in fact no session conflict anymore. It'd likely help to know what the 1006
is, but couldn't find how to get more debugging info about it.
本文标签: javascriptobswebsocketjs fails to connect through ngrok sometimes due to error 1006Stack Overflow
版权声明:本文标题:javascript - obs-websocket-js fails to connect through ngrok sometimes due to error 1006 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736591598a1945085.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论