ViscosityCC.exe connect should wait until connected and then exit

Got a problem with Viscosity or need help? Ask here!

asdffdsa6131

Posts: 31
Joined: Sat Feb 23, 2019 12:15 pm

Post by asdffdsa6131 » Sat Aug 17, 2024 10:07 am
hello, thanks,

i use viscosity because it has a nice gui and should be easy to work with and on the whole, very satisfied with the money i spent.
yet in some ways, using viscosity seems way to complicated and fragile.

i just want to run a simple command to start the connection, and return after the vpn is connected or return a non-zero exit code. same as most command line programs i use.

not having to run complex scripts as documented at https://www.sparklabs.com/support/kb/ar ... g-windows/

the sample batch script is 30+ lines and look very fragile, depending on pings for sleeping and looping and three ViscosityCC.exe commands. all that to simply connect to a vpn.

what can i do please, thanks?

Aaron

Posts: 32
Joined: Wed Nov 30, 2022 2:53 pm

Post by Aaron » Thu Aug 22, 2024 8:13 am
Hi,

Thanks for your feedback. Viscosity follows a semi-asynchronous model for scripting. This is because a VPN connection has far more than two states (Disconnected/Connected) and there are situations where it may never return. While I can understand it would be nice if the connect command simply blocked until a VPN connection was connected, there are lots of edge cases that should to be handled by the calling script.

For example, what happens if the VPN connection attempts to connect indefinitely (but isn't able to fully connect), what happens if the VPN connection is stuck in a connecting state waiting for input from the user (such as a username/password or two-factor code), what happens if the VPN connection is waiting for a network change, etc. While monitoring a VPN connection's status using polling isn't ideal, it does allow a script to decide how to handle status changes of the VPN connection after calling a command or implement custom timeouts. Polling can be done fairly simply like so using PowerShell (although it would generally be a good idea to add a timeout if the VPN connection never connects):
Code: Select all
Do {
	Start-Sleep -Milliseconds 500
} Until ((& $ViscosityCC getstate $ConnName) -eq "Connected")
Regards,
Aaron
Web: https://www.sparklabs.com
Support: https://www.sparklabs.com/support
Twitter: https://twitter.com/sparklabs
2 posts Page 1 of 1