1
0
Fork 0
mirror of https://github.com/pikvm/pikvm.git synced 2026-03-02 18:16:56 -05:00

When connecting using bvnc clipboard is pasted upon connect every time #960

Closed
opened 2026-02-20 14:09:04 -05:00 by deekerman · 14 comments
Owner

Originally created by @Raptor-TK on GitHub (Oct 30, 2024).

Originally assigned to: @mdevaev on GitHub.

Describe the bug
When connecting using bvnc, clipboard from android is pasted upon connect every time.

To Reproduce
Steps to reproduce the behavior, like:

  1. Have something in android clipboard
  2. Connect to pikvm vnc server using bvnc on android
  3. The clipboard is automatically pasted into the pikvm
  4. Pastes every time. Very annoying.

Expected behavior
The clipboard should not be pasted upon connect.

VNC client phone:

  • OS: Android 14
  • Browser N/A
  • Version [e.g. 22] android 14
  • VNC client (if used) bvnc

PiKVM info:

  • Raspberry Pi board version [e.g. RPi 4] RPi 4
  • PiKVM platform [e.g. v2-hdmi] DIY PiKVM V2 Platform hdmi to usb dongle version
  • Video capture type [e.g. CSI bridge] hdmi to usb
  • KVMD version: pacman -Q | grep kvmd 4.10
  • uStreamer version: pacman -Q | grep ustreamer 6.14
  • Linux kernel: uname -a Linux pikvm 6.6.45-7-rpi 1 SMP Mon Sep 2 09:16:27 UTC 2024 armv7l GNU/Linux

Additional context
KVMD: 4.10
Streamer: 6.14 (ustreamer)
HAS_PDEATHSIG: Yes
WITH_GPIO: Yes
WITH_PTHREAD_NP: Yes
WITH_SETPROCTITLE: Yes
WITH_SYSTEMD: Yes
Linux kernel:
Machine: armv7l
Release: 6.6.45-7-rpi
Version: #1 SMP Mon Sep 2 09:16:27 UTC 2024

Originally created by @Raptor-TK on GitHub (Oct 30, 2024). Originally assigned to: @mdevaev on GitHub. **Describe the bug** When connecting using bvnc, clipboard from android is pasted upon connect every time. **To Reproduce** Steps to reproduce the behavior, like: 1. Have something in android clipboard 2. Connect to pikvm vnc server using bvnc on android 3. The clipboard is automatically pasted into the pikvm 4. Pastes every time. Very annoying. **Expected behavior** The clipboard should not be pasted upon connect. **VNC client phone:** - OS: Android 14 - Browser N/A - Version [e.g. 22] android 14 - VNC client (if used) bvnc **PiKVM info:** - Raspberry Pi board version [e.g. RPi 4] RPi 4 - PiKVM platform [e.g. v2-hdmi] DIY PiKVM V2 Platform hdmi to usb dongle version - Video capture type [e.g. CSI bridge] hdmi to usb - KVMD version: `pacman -Q | grep kvmd` 4.10 - uStreamer version: `pacman -Q | grep ustreamer` 6.14 - Linux kernel: `uname -a` Linux pikvm 6.6.45-7-rpi 1 SMP Mon Sep 2 09:16:27 UTC 2024 armv7l GNU/Linux **Additional context** KVMD: 4.10 Streamer: 6.14 (ustreamer) HAS_PDEATHSIG: Yes WITH_GPIO: Yes WITH_PTHREAD_NP: Yes WITH_SETPROCTITLE: Yes WITH_SYSTEMD: Yes Linux kernel: Machine: armv7l Release: 6.6.45-7-rpi Version: #1 SMP Mon Sep 2 09:16:27 UTC 2024
deekerman 2026-02-20 14:09:04 -05:00
Author
Owner

@Raptor-TK commented on GitHub (Oct 30, 2024):

#284 #926 are related issues.

For 284, the user must of copied some logs when trying to debug something and upon connect it auto pasted.

@Raptor-TK commented on GitHub (Oct 30, 2024): #284 #926 are related issues. For 284, the user must of copied some logs when trying to debug something and upon connect it auto pasted.
Author
Owner

@Raptor-TK commented on GitHub (Oct 31, 2024):

I also noticed that this also happens on AVNC as well when connecting to PiKVM.
Tested and reproduce on a Samsung Fold 6 and a Sony Xperia Pro-i

@Raptor-TK commented on GitHub (Oct 31, 2024): I also noticed that this also happens on AVNC as well when connecting to PiKVM. Tested and reproduce on a Samsung Fold 6 and a Sony Xperia Pro-i
Author
Owner

@Raptor-TK commented on GitHub (Oct 31, 2024):

One workaround is to use an app like the following to clear the clipboard in android before connecting to the PiKVM.

https://github.com/amnesica/ClearClipboard

It can be automated using routines and setting a rule for the clear clipboard to be run whenever a vnc client is opened.

@Raptor-TK commented on GitHub (Oct 31, 2024): One workaround is to use an app like the following to clear the clipboard in android before connecting to the PiKVM. https://github.com/amnesica/ClearClipboard It can be automated using routines and setting a rule for the clear clipboard to be run whenever a vnc client is opened.
Author
Owner

@mdevaev commented on GitHub (Nov 2, 2024):

I suppose this is a problem on the client side. PiKVM receives a clipboard insertion signal from them and simply executes this command.

@mdevaev commented on GitHub (Nov 2, 2024): I suppose this is a problem on the client side. PiKVM receives a clipboard insertion signal from them and simply executes this command.
Author
Owner

@mdevaev commented on GitHub (Nov 2, 2024):

Please attach journalctl -u kvmd-vnc log with timestamps. If this event arrives immediately after the connection, I can add some delay during which clipboard events will be ignored.

@mdevaev commented on GitHub (Nov 2, 2024): Please attach `journalctl -u kvmd-vnc` log with timestamps. If this event arrives immediately after the connection, I can add some delay during which clipboard events will be ignored.
Author
Owner

@Raptor-TK commented on GitHub (Nov 2, 2024):

I reproduced the issue copying the word "Test" before connecting to the PiKVM several times.
In the log it prints:

Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server              INFO --- [::ffff:192.168.0.51]:46874 [kvmd]: Connected to KVMD websocket
Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server              INFO --- [::ffff:192.168.0.51]:46874 [streamer]: Using preferred MemsinkStreamerClient(JPEG)
Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server              INFO --- [::ffff:192.168.0.51]:46874 [streamer]: Streaming ...
Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server              INFO --- [::ffff:192.168.0.51]:46874 **[main]: Printing 4 characters ...**

kvmd-vnc.log

@Raptor-TK commented on GitHub (Nov 2, 2024): I reproduced the issue copying the word "Test" before connecting to the PiKVM several times. In the log it prints: ``` Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server INFO --- [::ffff:192.168.0.51]:46874 [kvmd]: Connected to KVMD websocket Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server INFO --- [::ffff:192.168.0.51]:46874 [streamer]: Using preferred MemsinkStreamerClient(JPEG) Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server INFO --- [::ffff:192.168.0.51]:46874 [streamer]: Streaming ... Nov 02 15:20:39 pikvm kvmd-vnc[502]: kvmd.apps.vnc.server INFO --- [::ffff:192.168.0.51]:46874 **[main]: Printing 4 characters ...** ``` [kvmd-vnc.log](https://github.com/user-attachments/files/17607458/kvmd-vnc.log)
Author
Owner

@mdevaev commented on GitHub (Nov 2, 2024):

Try this hack. Patch your file /usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py like this:

diff --git a/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py b/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py
index c145b4b3..461e6374 100644
--- a/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py
+++ b/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py
@@ -22,6 +22,7 @@

 import asyncio
 import ssl
+import time

 from typing import Callable
 from typing import Coroutine
@@ -92,6 +93,8 @@ class RfbClient(RfbClientStream):  # pylint: disable=too-many-instance-attribute

         self.__lock = asyncio.Lock()

+        self.__connect_ts = 0.0
+
     # =====

     async def _run(self, **coros: Coroutine) -> None:
@@ -414,6 +417,7 @@ class RfbClient(RfbClientStream):  # pylint: disable=too-many-instance-attribute
     # =====

     async def __main_loop(self) -> None:
+        self.__connect_ts = time.monotonic()
         handlers = {
             0: self.__handle_set_pixel_format,
             2: self.__handle_set_encodings,
@@ -499,7 +503,8 @@ class RfbClient(RfbClientStream):  # pylint: disable=too-many-instance-attribute
     async def __handle_client_cut_text(self) -> None:
         length = (await self._read_struct("cut text length", "xxx L"))[0]
         text = await self._read_text("cut text data", length)
-        await self._on_cut_event(text)
+        if self.__connect_ts > 0 and time.monotonic() > self.__connect_ts + 3:
+            await self._on_cut_event(text)

     async def __handle_enable_cont_updates(self) -> None:
         enabled = bool((await self._read_struct("enabled ContUpdates", "B HH HH"))[0])

If you do not know how to do this, I will send you the whole file.

@mdevaev commented on GitHub (Nov 2, 2024): Try this hack. Patch your file `/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py` like this: ```diff diff --git a/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py b/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py index c145b4b3..461e6374 100644 --- a/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py +++ b/usr/lib/python3.12/site-packages/kvmd/apps/vnc/rfb/__init__.py @@ -22,6 +22,7 @@ import asyncio import ssl +import time from typing import Callable from typing import Coroutine @@ -92,6 +93,8 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute self.__lock = asyncio.Lock() + self.__connect_ts = 0.0 + # ===== async def _run(self, **coros: Coroutine) -> None: @@ -414,6 +417,7 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute # ===== async def __main_loop(self) -> None: + self.__connect_ts = time.monotonic() handlers = { 0: self.__handle_set_pixel_format, 2: self.__handle_set_encodings, @@ -499,7 +503,8 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute async def __handle_client_cut_text(self) -> None: length = (await self._read_struct("cut text length", "xxx L"))[0] text = await self._read_text("cut text data", length) - await self._on_cut_event(text) + if self.__connect_ts > 0 and time.monotonic() > self.__connect_ts + 3: + await self._on_cut_event(text) async def __handle_enable_cont_updates(self) -> None: enabled = bool((await self._read_struct("enabled ContUpdates", "B HH HH"))[0]) ``` If you do not know how to do this, I will send you the whole file.
Author
Owner

@mdevaev commented on GitHub (Nov 2, 2024):

Updated ^^^

@mdevaev commented on GitHub (Nov 2, 2024): Updated ^^^
Author
Owner

@Raptor-TK commented on GitHub (Nov 3, 2024):

Thanks I'll try this and update you when I've tested it.

@Raptor-TK commented on GitHub (Nov 3, 2024): Thanks I'll try this and update you when I've tested it.
Author
Owner

@Raptor-TK commented on GitHub (Nov 4, 2024):

It works!
Tested it several times with both AVNC and bVNC clients in android.

Thank you for resolving this issue!

@Raptor-TK commented on GitHub (Nov 4, 2024): It works! Tested it several times with both AVNC and bVNC clients in android. Thank you for resolving this issue!
Author
Owner

@mdevaev commented on GitHub (Nov 4, 2024):

You're welcome. It will be available in the next release also.

@mdevaev commented on GitHub (Nov 4, 2024): You're welcome. It will be available in the next release also.
Author
Owner

@Raptor-TK commented on GitHub (Nov 4, 2024):

Actually, I jumped the gun.
I found another scenario it happens.

When VNC Client is running but was running in background but not disconnected.
If you switch focus back to it, the clipboard contents is pasted still.

In this case I'm not sure if there is an easy solution.
But at least the situation of it pasting the clipboard on the initial connect is not happening.

@Raptor-TK commented on GitHub (Nov 4, 2024): Actually, I jumped the gun. I found another scenario it happens. When VNC Client is running but was running in background but not disconnected. If you switch focus back to it, the clipboard contents is pasted still. In this case I'm not sure if there is an easy solution. But at least the situation of it pasting the clipboard on the initial connect is not happening.
Author
Owner

@mdevaev commented on GitHub (Nov 5, 2024):

There's no way I can fix it. VNC is not really designed for something like PiKVM, and clients are trying to synchronize clipboard contents with the host. But PiKVM doesn't have a clipboard, only keyboard access, so it tries to type this.

@mdevaev commented on GitHub (Nov 5, 2024): There's no way I can fix it. VNC is not really designed for something like PiKVM, and clients are trying to synchronize clipboard contents with the host. But PiKVM doesn't have a clipboard, only keyboard access, so it tries to type this.
Author
Owner

@Raptor-TK commented on GitHub (Nov 5, 2024):

Thanks for the hint there that this is likely something that needs solving on the client side.

I checked in AVNC client for android and there is an option to disable clipboard sync that solves this issue.
In bVNC on android, there is no option to disable clipboard sync.

@Raptor-TK commented on GitHub (Nov 5, 2024): Thanks for the hint there that this is likely something that needs solving on the client side. I checked in AVNC client for android and there is an option to disable clipboard sync that solves this issue. In bVNC on android, there is no option to disable clipboard sync.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pikvm-pikvm#960
No description provided.