obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
657 stars 95 forks source link

OBS update to obs-websocket version 5.4.2 preventing connection to obs-websocket-js version 5.0.5 #354

Open V-u-b-a-r opened 2 months ago

V-u-b-a-r commented 2 months ago

Description:

OBS updated it's websocket settings, which is now preventing me from connecting to the websocket at all. Release notes are:

Updated obs-websocket to version 5.4.2 [tt2468/Lain-B] Release notes for addition in 5.4.0 are here: https://github.com/obsproject/obs-websocket/releases/tag/5.4.0

And release notes:

base: Update version to 5.4.0 @tt2468 tt2468 tagged this Jan 25 New Features:

  • Added GetSourceFilterKindList request
  • Added GetSceneItemSource request
  • Added InputSettingsChanged event
  • Added SourceFilterSettingsChanged event
  • Added UUID support to Sources (Inputs/Scenes), Inputs, Scenes, Transitions
    • The Source requests/events use sourceUuid
    • The Input requests/events use inputUuid
    • The Scene requests/events use sceneUuid
    • The Transition requests/events use transitionUuid
    • Filters do not have support for UUIDs at this time.

Enhancements:

  • Added contextName field to TriggerHotkeyByName (exeldro)

Bug Fixes:

  • Fixed a crash on shutdown with notifications enabled (r1ch)
  • Added safety check to prevent null outputCongestion values in GetStreamStatus
  • Fixed a memory leak when switching service kinds via SetStreamServiceSettings

Other Notes:

  • Documented missing outputActive ToggleRecord response field
  • Added a few new client softwares to the README list
  • Removed a mis-documented imageData field
  • Added a note to the hotkey requests that they are as-is and we will not provide support for them

Versions Used (if applicable):

Code sample:

My connection code, which connected before the OBS update and does not now (note it does not throw an error either):

async function connectToObs() {
  try {
    const { obsWebSocketVersion, negotiatedRpcVersion } = await obs.connect(
      'ws://localhost:4455', 
      { rpcVersion: 1 }
    );

    console.log(`Connected to OBS WebSocket v${obsWebSocketVersion} using RPC version ${negotiatedRpcVersion}`);
    reconnectAttempts = 0;

    obs.on('ConnectionClosed', () => {
        console.log('OBS connection closed. Attempting to reconnect...');
        attemptObsReconnect();
    });

    obs.on('ConnectionError', (error) => {
        console.error('OBS connection error:', error);
        attemptObsReconnect();
    });

    process.on('SIGINT', async () => {
        console.log('Process terminated. Closing OBS WebSocket connection...');
        try {
            disconnectObs();
        } catch (error) {
            console.error('Error closing OBS WebSocket connection:', error);
        }
        process.exit(0); // Optional: Forcefully terminate process after disconnection
    });

    process.on('SIGTERM', async () => {
        console.log('Process terminated. Closing OBS WebSocket connection...');
        try {
            disconnectObs();
        } catch (error) {
            console.error('Error closing OBS WebSocket connection:', error);
        }
        process.exit(0); // Optional: Forcefully terminate process after disconnection
    });
  } catch (error) {
    console.error('Failed to connect:', error);
    attemptObsReconnect();
  }
}
V-u-b-a-r commented 2 months ago

Update: It now appears to be working again... Maybe there was something out of sync after the OBS update, that has corrected itself now... but I'll monitor this for a few more streams and then close if it's stable.