obs-websocket-js 连接失败。服务器未发送子协议。

huangapple go评论96阅读模式
英文:

obs-websocket-js failed to connect. Server sent no subprotocol

问题

我想使用obs-websocket-js包来构建一个通过websocket连接到OBS Studio的应用程序。
当我尝试运行连接函数时,我遇到了Failed to connect -1 Server sent no subprotocol错误。

OBS Studio正在运行于我系统上的Oracle VM VirtualBox上的Ubuntu 20.01上。

obs-websocket-js 连接失败。服务器未发送子协议。

Node.JS代码:

const OBSWebSocket = require("obs-websocket-js").default;

const obs = new OBSWebSocket();

const connect = async () => {
  try {
     const { obsWebSocketVersion, negotiatedRpcVersion } = await obs.connect("ws://192.168.100.170:4444",undefined, {rpcVersion: 1});

    return `Connected to server ${obsWebSocketVersion} (using RPC ${negotiatedRpcVersion})`;
  } catch (error) {
    console.error("Failed to connect", error.code, error.message);
  }
};

connect().then((value) => console.log(value));

我希望能够成功连接并找出为什么会出现"Server sent no subprotocol"错误。

英文:

I want to use obs-websocket-js package to build an app to connect to OBS Studio through websocket.
When I try running the connection function, I get a Failed to connect -1 Server sent no subprotocol error.

The OBS Studio is running on Ubuntu 20.01 which is on a Oracle VM VirtualBox on my system.

obs-websocket-js 连接失败。服务器未发送子协议。

Node.JS code:

const OBSWebSocket = require("obs-websocket-js").default;

const obs = new OBSWebSocket();

const connect = async () => {
  try {
     const { obsWebSocketVersion, negotiatedRpcVersion } = await obs.connect("ws://192.168.100.170:4444",undefined, {rpcVersion: 1});

    return `Connected to server ${obsWebSocketVersion} (using RPC ${negotiatedRpcVersion})`;
  } catch (error) {
    console.error("Failed to connect", error.code, error.message);
  }
};

connect().then((value) => console.log(value));

I expect to make a succesful connection and to find out why I have a Server sent no subprotocol error.

答案1

得分: 1

我找到了一个非常简单的解决方案:我将OBS Studio更新到最新的29.0.0版本,然后它就可以正常工作了。

英文:

I found a very simple solution: I updated the OBS Studio to the latest 29.0.0 version and it worked.

huangapple
  • 本文由 发表于 2023年1月10日 16:35:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75067348.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定