Client side events

I'm testing, how my application behaves when there is a network problem between VirtualHere server and client. After connection is lost between VirtualHere server and client, client side remove the usb device, but it seems that onClientBeforeUnbind and onClientAfterUnbind events are not executed when connection is lost.

Client side API describes following events:
onClientBeforeBind - occurs just before a remote device is bound to the client
onClientAfterBind - just after...
onClientBeforeUnbind - just before a remote device is UNbound from the client
onClientAfterUnbind - just after...

Is there client side event about connection lost?

Log:
Mar 10 12:52:04 ubuntu VirtualHere Client: VirtualHere Client 4.4.5 starting (Compiled: Feb 26 2018 18:19:26)
Mar 10 12:52:04 ubuntu VirtualHere Client: Using config at /home/pali/.vhui
Mar 10 12:52:04 ubuntu VirtualHere Client: IPC available at /tmp/vhclient
Mar 10 12:52:04 ubuntu VirtualHere Client: Auto-find using Bonjour - on
Mar 10 12:52:04 ubuntu VirtualHere Client: Auto-find using Bonjour SSL - on
Mar 10 12:52:04 ubuntu VirtualHere Client: VirtualHere USB Server Trial Edition (192.168.10.10:7575)
Mar 10 12:53:04 ubuntu VirtualHere Client: VirtualHere CloudHub Free Edition for the Pi3 (192.168.40.40:7575)
Mar 10 12:53:04 ubuntu VirtualHere Client: Executed /Events/onClientBeforeBind.0403.6001 "echo `date`: onClientBeforeBind >> /tmp/test.log" returned 0
Mar 10 12:53:05 ubuntu kernel: [73042.217002] vhci_hcd vhci_hcd: rhport(0) sockfd(18) devid(4) speed(2) speed_str(full-speed)
Mar 10 12:53:05 ubuntu VirtualHere Client: Executed /Events/onClientAfterBind.0403.6001 "echo `date`: onClientAfterBind >> /tmp/test.log;/home/pali/on.sh" returned 0
Mar 10 12:53:05 ubuntu kernel: [73042.431700] usb 2-1: new full-speed USB device number 30 using vhci_hcd
Mar 10 12:53:05 ubuntu kernel: [73042.551695] usb 2-1: SetAddress Request (30) to port 0
Mar 10 12:53:05 ubuntu kernel: [73042.616899] usb 2-1: New USB device found, idVendor=0403, idProduct=6001
Mar 10 12:53:05 ubuntu kernel: [73042.616910] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Mar 10 12:53:05 ubuntu kernel: [73042.616913] usb 2-1: Product: RFXtrx433
Mar 10 12:53:05 ubuntu kernel: [73042.616915] usb 2-1: Manufacturer: RFXCOM
Mar 10 12:53:05 ubuntu kernel: [73042.616917] usb 2-1: SerialNumber: 06VVEG1Y
Mar 10 12:53:05 ubuntu kernel: [73042.625768] ftdi_sio 2-1:1.0: FTDI USB Serial Device converter detected
Mar 10 12:53:05 ubuntu kernel: [73042.625795] usb 2-1: Detected FT232RL
Mar 10 12:53:05 ubuntu kernel: [73042.630678] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0
Mar 10 12:53:37 ubuntu VirtualHere Client: Server ping timeout, shutting down connection 2...
Mar 10 12:53:37 ubuntu VirtualHere Client: Connection 2 remotely disconnected gracefully (rx)
Mar 10 12:53:37 ubuntu kernel: [73074.962903] vhci_hcd: connection closed
Mar 10 12:53:37 ubuntu kernel: [73074.963042] vhci_hcd: stop threads
Mar 10 12:53:37 ubuntu kernel: [73074.963048] vhci_hcd: release socket
Mar 10 12:53:37 ubuntu kernel: [73074.963056] vhci_hcd: disconnect device
Mar 10 12:53:37 ubuntu kernel: [73074.963097] usb 2-1: USB disconnect, device number 30
Mar 10 12:53:37 ubuntu kernel: [73074.963268] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
Mar 10 12:53:37 ubuntu kernel: [73074.963281] ftdi_sio 2-1:1.0: device disconnected

#2

I use udev rules on my client side.
For example when the usb got disconnected i use this:

ACTION=="remove", SUBSYSTEM=="usb", ENV{ID_MODEL_ID}=="8268", ENV{ID_VENDOR_ID}=="2040", RUN+="/bin/sh /home/tvheadend/remount.sh"

Ofcourse you got to change your Vendor and Model ID and the script you wanna use

#3

Thanks daschacka,

I'm actually aware of that and already succesfully tested that as well. udev behaviour is pretty poorly documented. Do you know is udev run script executed before or after dev is removed? If it's executed before, does udev wait that script execution is completed before continue? And what then happens if script doesn't ever return, does it jam the udev?

#4

@Pali, actually the onClientBefore/AfterUnbind script is only run when the virtualhere connection is still available. For technical reasons it cant run if the connection is dropped already (this is sort of a bug actually but its best to use udev instead anyway)

#5

Ok, thanks

#6

Hi.
I want to capture the status of a device connected to the server (eg printer in use at pc1 - user-john) and use it in the powershell script (will install the client as a server).Can somebody help me with this .Thanks.