[GH-ISSUE #246] Scenario "mobile client": Support for multiple servers per client? #197

Open
opened 2026-05-05 05:39:36 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @kakra on GitHub (Feb 4, 2019).
Original GitHub issue: https://github.com/debauchee/barrier/issues/246

I installed a Barrier client 2.1.2 on a Windows laptop. This machine is used at different locations as a companion machine to different stationary PCs (thus in different network locations).

I'm currently using two Barrier servers: One Gentoo Linux machine (2.1.2) at work, and another Gentoo Linux machine (also 2.1.2) at home.

I didn't currently find a way to reliably connect the client with multiple servers (so it would pick the one that's available). Instead, I need to open the client config and change the server IP to connect to.

Is this scenario a supported use-case? The auto-config mode doesn't seem to work: I'm forced to enter an IP / hostname in the client configuration although the field will be disabled when auto-config is enabled. It would help if I could just give it multiple comma-separated hostnames in the server input field.

Originally created by @kakra on GitHub (Feb 4, 2019). Original GitHub issue: https://github.com/debauchee/barrier/issues/246 I installed a Barrier client 2.1.2 on a Windows laptop. This machine is used at different locations as a companion machine to different stationary PCs (thus in different network locations). I'm currently using two Barrier servers: One Gentoo Linux machine (2.1.2) at work, and another Gentoo Linux machine (also 2.1.2) at home. I didn't currently find a way to reliably connect the client with multiple servers (so it would pick the one that's available). Instead, I need to open the client config and change the server IP to connect to. Is this scenario a supported use-case? The auto-config mode doesn't seem to work: I'm forced to enter an IP / hostname in the client configuration although the field will be disabled when auto-config is enabled. It would help if I could just give it multiple comma-separated hostnames in the server input field.
gitea-mirror added the
enhancement
label 2026-05-05 05:39:36 -06:00
Author
Owner

@dnunes commented on GitHub (Jan 25, 2021):

Any updates on this? I run a dual boot setup (Ubuntu 20.04 + Windows 10) with my server machine and have a companion (Windows 10) that have no keyboard/mouse attached to it, used for specific tasks. It's quite inconvenient to get a mouse to configure the second machine every time I switch OS. I would like to connect both OSes to the companion machine, but couldn't quite figure out if this is supported or not.

<!-- gh-comment-id:767163778 --> @dnunes commented on GitHub (Jan 25, 2021): Any updates on this? I run a dual boot setup (Ubuntu 20.04 + Windows 10) with my server machine and have a companion (Windows 10) that have no keyboard/mouse attached to it, used for specific tasks. It's quite inconvenient to get a mouse to configure the second machine every time I switch OS. I would like to connect both OSes to the companion machine, but couldn't quite figure out if this is supported or not.
Author
Owner

@sebbean commented on GitHub (Sep 10, 2021):

SHOULD WE BUILD IT? @mincedmit

<!-- gh-comment-id:916563274 --> @sebbean commented on GitHub (Sep 10, 2021): SHOULD WE BUILD IT? @mincedmit
Author
Owner

@Gustavobtfelix commented on GitHub (Sep 24, 2021):

hope you guys figure it out. I'm also trying to use multiple servers to client associations. to no vail until now. What i'm planning to do is using Team Viewer or VNC to access a server so that i can use it from various places.

<!-- gh-comment-id:926667715 --> @Gustavobtfelix commented on GitHub (Sep 24, 2021): hope you guys figure it out. I'm also trying to use multiple servers to client associations. to no vail until now. What i'm planning to do is using Team Viewer or VNC to access a server so that i can use it from various places.
Author
Owner

@maldex commented on GitHub (Jan 8, 2023):

I found a (windows) way that works for me: probing servers!
The Windows Task Scheduler can be triggered upon 'On Workstation Unlock': run a discovery-script whenever i revive my current windows session.

When changing my location beween Home, Work and Lab, i usually put my Laptop into sleep/hibernate/lid-Lock, after which i need to unlock windows again: thats when i want to find my local barrier-servers

Allthough this takes some seconds each time, it allows me to kvm my laptop on various desks

create serverlist

enter your servers line by line

notepad %LOCALAPPDATA%\BarrierClientFindLocalServer.servers

disable barrierd service

barrierd.exe as windows service is sleek for 'static' setups (where the client stays in the same network with the same server). With this proposed solution, we dynamically use barrierc.exe to connect to whatever server.

# run this as administrator
Set-Service -Name "Barrier" -Status Stopped -StartupType Manual

create onUnlock Scheduled Task

create a scheduled task to run

# run this as administrator, 
# set-location to where you put the BarrierClientFindLocalServer.ps1
# create the scheduled task


$stateChangeTrigger = Get-CimClass -Namespace ROOT\Microsoft\Windows\TaskScheduler -ClassName MSFT_TaskSessionStateChangeTrigger
$onUnlockTrigger = New-CimInstance -CimClass $stateChangeTrigger -Property @{ StateChange = 8 } -ClientOnly
$settings = New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 5)
$action = New-ScheduledTaskAction -WorkingDirectory $(Get-Location).Path -Execute "powershell.exe" -Argument ('-NoLogo -NonInteractive -WindowStyle hidden .\BarrierClientFindLocalServer.ps1')

Unregister-ScheduledTask -TaskName "BarrierClientFindLocalServer" -Confirm:$false -ErrorAction SilentlyContinue
Register-ScheduledTask -TaskName "BarrierClientFindLocalServer" -Trigger $onUnlockTrigger -Action $action -Settings $settings

StateChangeType 8 is TASK_SESSION_STATE_CHANGE_TYPE.TASK_SESSION_UNLOCK (taskschd.h) thx

BarrierClientFindLocalServer.ps1

#!/usr/bin/env powershell -File

# little script to probe various Barrier-Servers and start client against an available one

# get list of possible servers from file
foreach ($server in Get-Content "$env:LOCALAPPDATA\BarrierClientFindLocalServer.servers"){
  # test if tcp port 24800 is reachable
  if ( (Test-NetConnection -port 24800 -ComputerName $server -WarningAction SilentlyContinue -ErrorAction SilentlyContinue).TcpTestSucceeded ){ break; }
}

# stop previous instance
Stop-Process -Force -Name "barrierc" -ErrorAction Ignore

Start-Sleep -Milliseconds 250

# start new instance
Start-Process -NoNewWindow -FilePath "$env:ProgramFiles\barrier\barrierc.exe" `
  -ArgumentList "--debug INFO --log $env:TEMP\BarrierClient.log --name $env:COMPUTERNAME --enable-drag-drop  --disable-crypto $server"
<!-- gh-comment-id:1374921416 --> @maldex commented on GitHub (Jan 8, 2023): I found a (windows) way that works for me: probing servers! The Windows Task Scheduler can be triggered upon 'On Workstation Unlock': run a discovery-script whenever i revive my current windows session. When changing my location beween Home, Work and Lab, i usually put my Laptop into sleep/hibernate/lid-Lock, after which i need to unlock windows again: thats when i want to find my local barrier-servers Allthough this takes some seconds each time, it allows me to kvm my laptop on various desks ### create serverlist enter your servers line by line ```bat notepad %LOCALAPPDATA%\BarrierClientFindLocalServer.servers ``` ### disable barrierd service barrierd.exe as windows service is sleek for 'static' setups (where the client stays in the same network with the same server). With this proposed solution, we dynamically use barrierc.exe to connect to whatever server. ```powershell # run this as administrator Set-Service -Name "Barrier" -Status Stopped -StartupType Manual ``` ### create onUnlock Scheduled Task create a scheduled task to run ```powershell # run this as administrator, # set-location to where you put the BarrierClientFindLocalServer.ps1 # create the scheduled task $stateChangeTrigger = Get-CimClass -Namespace ROOT\Microsoft\Windows\TaskScheduler -ClassName MSFT_TaskSessionStateChangeTrigger $onUnlockTrigger = New-CimInstance -CimClass $stateChangeTrigger -Property @{ StateChange = 8 } -ClientOnly $settings = New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 5) $action = New-ScheduledTaskAction -WorkingDirectory $(Get-Location).Path -Execute "powershell.exe" -Argument ('-NoLogo -NonInteractive -WindowStyle hidden .\BarrierClientFindLocalServer.ps1') Unregister-ScheduledTask -TaskName "BarrierClientFindLocalServer" -Confirm:$false -ErrorAction SilentlyContinue Register-ScheduledTask -TaskName "BarrierClientFindLocalServer" -Trigger $onUnlockTrigger -Action $action -Settings $settings ``` *StateChangeType 8 is TASK_SESSION_STATE_CHANGE_TYPE.TASK_SESSION_UNLOCK (taskschd.h) [thx](https://stackoverflow.com/questions/53704188/syntax-for-execute-on-workstation-unlock)* ### _BarrierClientFindLocalServer.ps1_ ```powershell #!/usr/bin/env powershell -File # little script to probe various Barrier-Servers and start client against an available one # get list of possible servers from file foreach ($server in Get-Content "$env:LOCALAPPDATA\BarrierClientFindLocalServer.servers"){ # test if tcp port 24800 is reachable if ( (Test-NetConnection -port 24800 -ComputerName $server -WarningAction SilentlyContinue -ErrorAction SilentlyContinue).TcpTestSucceeded ){ break; } } # stop previous instance Stop-Process -Force -Name "barrierc" -ErrorAction Ignore Start-Sleep -Milliseconds 250 # start new instance Start-Process -NoNewWindow -FilePath "$env:ProgramFiles\barrier\barrierc.exe" ` -ArgumentList "--debug INFO --log $env:TEMP\BarrierClient.log --name $env:COMPUTERNAME --enable-drag-drop --disable-crypto $server" ```
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: github-starred/barrier#197
No description provided.