VNC Traffic killing thread

Hi all,
Me again with more basic questions. I’m trying to get the VNC to work, but i’m running into issues with stuff happening under the hood I don’t have access to. I borrowed the source code off of github so I could step through and see what was going on, but I’m having issues with the thread that runs the VncServer object permanently suspending on its own - there are no function calls to suspend this thread for more than a few ms at a time, but it seems after heavy traffic (moving the mouse around mostly) the thread will kill itself and will not restart. If i don’t move the mouse onto the screen, it works great, but as soon as it’s getting a bunch of mouse data it quits. All my code is using is the demo code on github with a little extra stuff to run a physical screen.

The objects still think they’re connected and open, but their code isn’t being executed so the VNC viewer will lose connection. Where should I start looking? troubleshooting multithreaded code is a bit of a bear. it’s also slowing my main thread to a crawl when it is in this state, so my best guess is there is some blocking call somewhere, but I don’t understand why that would keep my main thread from running too - especially when these are the only two running threads and one is suspended.

Edit - I learned that the ethernet port itself is also running on another thread, would that have any bearing on this?

We will take a look.

There is a property DelayBetweenFrame that you can use as suspend, by increase this value.

No dice, unfortunately even on a 2-3 second interval it still doesn’t behave. I don’t think its with the VNC drivers. Even with the mouse data taken entirely out of the logic beyond just reading the data from the stream, it will still cause it to crash. There’s no exception or anything, it just quits working.

Unplug your mouse! I am joking of course. Do you want to create a GitHub issue?

Sure.

Also @Dat_Tran here’s video if you want a better reference.

This is not hard to fix, so don’t worry.

1 Like

This is not hard to fix, so don’t worry.

Hey @Dat_Tran, would you be willing to share how you fixed this? i reverse engineered the RFB to create a viewer for a separate SitCore board, and i’m running into the same issue on the other side. What is the root cause of this particular issue?

I am willing to share but I am not sure what issue you talking about?

Is it moving mouse kill VNC?

Correct. For some reason, sending the touch data as mouse information using this method actually is killing the ethernet on the sender side.

private void WritePointerEvent(bool pressed)
        {
            lock (VncSocket)
            {
                writer.WriteByte((byte)ClientMessages.PointerEvent);
                Flush();
                Thread.Sleep(10);
                writer.WriteByte((byte)(pressed ? 0x01 : 0x00));
                WriteUInt16((ushort)x);
                WriteUInt16((ushort)y);
                Flush(); 
            }
        }

I can look into it more, but before i reinvented the wheel i wanted to see if this was a similar problem that has already been solved.

Our library is open src

look at

Disregard this message - I’m a moron. I’m not writing the padding so it’s getting out of sync and crashing.