question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] `Disconnected` event gets incorrect values

See original GitHub issue

Issue Type

  • Bug

Describe the bug The Disconnected event returns only values from WebSocketCloseStatus (1000-1011) and marks them as ObsCloseCodes. Whereas the OBS protocol returns the values 0, 4000, 4002, 4003-4012.

To Reproduce Steps to reproduce the behavior:

  1. Connect to OBS
  2. Place the breakpoint on OBSWebsocket.OnWebsocketDisconnect()
  3. Close OBS
  4. Check the variable d.CloseStatus

Expected behavior Probably I would like to get either a combined enum from the OBS protocol and the WebSocket enum, or get some kind of remap of WebSocket values to the values from the OBS protocol enum.

Screenshots image

image

Versions OBS Version: 28.0.1 OBS WebSocket Version: OBS WebSocket Dotnet (this library) Version: 257e7b48e1c365fcf2ea3de9f156ded2bf8f5247 OS: Windows 11

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BarRaidercommented, Nov 24, 2022

I will address this moving forward

0reactions
ProbablePrimecommented, Nov 23, 2022

I too am seeing 1000, 1001 etc coming in this handler from e.ObsCloseCode

In my case, connect to OBS, then force close OBS -> 1001.

You asked for a reproduction:

using OBSWebsocketDotNet;
using OBSWebsocketDotNet.Communication;

namespace OBSWebsocketTest
{
    public class Program
    {
        public static Task Main(string[] args) => new Program().MainAsync();
        public async Task MainAsync()
        {
            OBSWebsocket obs = new OBSWebsocket();

            obs.Connected += Obs_Connected;
            obs.Disconnected += Obs_Disconnected;
            obs.ConnectAsync("ws://127.0.0.1:4455", "");

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
        void Obs_Connected(object? sender, EventArgs e)
        {
            Console.WriteLine("Connected");
        }

        void Obs_Disconnected(object? sender, ObsDisconnectionInfo e)
        {
            Console.WriteLine(e.ObsCloseCode);
        }
  

Running this, with OBS open, waiting till you see connected and then closing OBS will result in a 1001 close code.

I think the original poster is saying that the additional codes(<4000) are not documented in the library and that the type(ObsCloseCodes) does not handle them. This leads to a confusing experience when consuming this client.

I guess that when I consume a client application, I expect an Enum value to not contain values that are not defined in the Enum.

If I were writing this library I would probably either:

  1. Extends ObsCloseCodes from another Enum type that does contain codes <4000
  2. Change the handling/invocation of the disconnected handler to not send <4000 codes via the ObsCloseCodes type.

In my case, I can handle this with some extra code similar to the original poster, but I do agree with them it is confusing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: Network changed events fired with a delay #13375
I believe I'm seeing a related issue. Metamask (injected provider) disconnects whenever the chain is changed to the Binance Test Network.
Read more >
Remote Desktop Error "You have been disconnected ...
It happens with both. Until recently, it happened with neither. It occurs when the connection is dropped due to an unreliable connection.
Read more >
Understanding Disconnect / Reconnect Process and Error ...
When I disable wifi it takes pusher 4 seconds to notice and change the state to disconnected and then to unavailable .
Read more >
Bug - Buffer Overflow after disconnection
It's pretty weird that it only happens when there are multiple client connections though, I'd expect the issue to arise even with one...
Read more >
How to Resolve Remote Desktop Disconnected Error
Objective: To resolve the Remote desktop disconnected error due to incorrect configuration of authentication and encryption settings. Incorrectly configured ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found