OpenVPN Connect intents changed?

Official client software for OpenVPN Access Server and OpenVPN Cloud.
Post Reply
Loren Ward
OpenVpn Newbie
Posts: 1
Joined: Thu Feb 15, 2018 5:37 pm

OpenVPN Connect intents changed?

Post by Loren Ward » Thu Feb 15, 2018 5:39 pm

I've been using Tasker to automatically connect/disconnect and add manual buttons for a while and it has been working great. After I updated the app yesterday my tasks no longer work.

Did the intents change? What do I need to do to fix it?

Here's what I used to set it up originally

fmeyer1
OpenVpn Newbie
Posts: 2
Joined: Thu Feb 15, 2018 7:15 pm

Re: OpenVPN Connect intents changed?

Post by fmeyer1 » Thu Feb 15, 2018 7:19 pm

I am having the exact same problem. I got to work this morning and noticed that my Tasker task was no longer auto connecting me to my VPN. After some troubleshooting I believe that the intents have clanged with the new OpenVPN Connect android app update. I have yet to find a solution.

ievgen
OpenVpn Newbie
Posts: 2
Joined: Fri Feb 16, 2018 10:26 am

Re: OpenVPN Connect intents changed?

Post by ievgen » Fri Feb 16, 2018 12:25 pm

Please use following options for new version of OpenVPN Connect application:

1. CONNECT

a) Access Server module
Action: net.openvpn.openvpn.CONNECT
OR
Action: android.intent.action.VIEW
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:AS {your_profile_name}
Extra: net.openvpn.openvpn.AUTOCONNECT:true
Extra: net.openvpn.openvpn.APP_SECTION:AS
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity

b) OVPN Profile module
Action: net.openvpn.openvpn.CONNECT
OR
Action: android.intent.action.VIEW
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:PC {your_profile_name}
Extra: net.openvpn.openvpn.AUTOCONNECT:true
Extra: net.openvpn.openvpn.APP_SECTION:PC
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity

2. DISCONNECT
Action: net.openvpn.openvpn.DISCONNECT
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.STOP:true
Extra: {blank}
Extra: {blank}
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity

lcasale
OpenVpn Newbie
Posts: 2
Joined: Thu Feb 15, 2018 11:41 pm

Re: OpenVPN Connect intents changed?

Post by lcasale » Fri Feb 16, 2018 2:36 pm

b) OVPN Profile module
Action: net.openvpn.openvpn.CONNECT
OR
Action: android.intent.action.VIEW
Cat: None
Mime Type: {blank}
Data: {blank}
Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME:PC {your_profile_name}
Extra: net.openvpn.openvpn.AUTOCONNECT:true
Extra: net.openvpn.openvpn.APP_SECTION:PC
Package: net.openvpn.openvpn
Class: net.openvpn.unified.MainActivity
Target: Activity
This worked, thanks!

cvnk
OpenVpn Newbie
Posts: 2
Joined: Fri Feb 16, 2018 6:25 pm

Re: OpenVPN Connect intents changed?

Post by cvnk » Fri Feb 16, 2018 6:27 pm

Thanks for the updated info. This appears to solve the problem for Tasker but now I need to figure out why OpenVPN immediately auto-reconnects after Tasker shuts down the connection.

I don't want OpenVPN running when I'm using cellular data.

ievgen
OpenVpn Newbie
Posts: 2
Joined: Fri Feb 16, 2018 10:26 am

Re: OpenVPN Connect intents changed?

Post by ievgen » Mon Feb 19, 2018 12:53 pm

Hi lcasale,
Cellular data issue - I think you can set restriction for using internet for OpenVPN connect application. You can use following article for doing this - https://www.makeuseof.com/tag/prevent-a ... a-android/

Reconnect issue - could you provide more information about this nuance. I cannot reproduce it on my device. You can share this information here or send it to our support - android@openvpn.net

cvnk
OpenVpn Newbie
Posts: 2
Joined: Fri Feb 16, 2018 6:25 pm

Re: OpenVPN Connect intents changed?

Post by cvnk » Tue Feb 20, 2018 5:33 pm

It looks like I have the reconnect issue solved. It seems to be related to how the connection was first started. If you connect using the slider in the app then disconnecting via Tasker results in the app automatically reconnecting.

I was resorting to the slider because my CONNECT task wasn't initiating the connection properly. Then I noticed I had a typo in the "Class" field (on the DISCONNECT task too): I had included a second ".openvpn" in the URL.

Now that I've corrected that Tasker is able to start OpenVPN successfully and when it shuts down the connection stays shut down.

Thanks for your attention to this. I realize dealing with Tasker isn't your responsibility but it seems you realize a lot of us chose your application because it could be automated like this.

BTW: I was the one concerned about OpenVPN being active while on cellular data. The reason I don't want it running is because my provider (T-Mobile) doesn't count certain types of traffic such as streaming music and video against my data cap but if that data is routed through the VPN connection they can't see where it's coming from and exclude it. That's all. I mainly just use a VPN to protect myself on public wifi hot spots.

Composit
OpenVpn Newbie
Posts: 2
Joined: Wed Feb 28, 2018 5:44 pm

Re: OpenVPN Connect intents changed?

Post by Composit » Wed Feb 28, 2018 6:22 pm

May I jump in to this topic ?
Before upgrade of OpenVPN Connect to 3.0 I used the following code in my app to start and stop the VPN-Connection.
Documented here: yes, it was my post ;)
startVPN brought OpenVPN Connect to the foreground startet VPN-connection and then put OpenVPN Connect to the background - almost perfect ;)

Code: Select all

private void startVPN() {
        Intent openVPN = new Intent();
        openVPN.setPackage("net.openvpn.openvpn");
        openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.openvpn.OpenVPNClient");
        openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "my.company.com [openvpn]");
        startActivity(openVPN);
    }
stopVPN stopped the connection entirely in background - perfect.

Code: Select all

private void stopVPN() {
        Intent openVPN = new Intent("android.intent.action.VIEW");
        openVPN.setPackage("net.openvpn.openvpn");
        openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.openvpn.OpenVPNDisconnect");
        startActivityForResult(openVPN, 0);
Since version 3.0 this is no longer supported and I tried to adapt the information provided above in this topic.
Currently I use v3.0.2

After some tries my app is able to launch OpenVPN Connect but it does no autoconnect :cry:
Stopping the connection works too but OpenVPN Connect stays in foreground.

Here the code I tried with lots of variations:

Code: Select all

private void startVPN() {
        Intent openVPN = new Intent();
        openVPN.setPackage("net.openvpn.openvpn");
        openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity");
        openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "my.company.com [openvpn]");
        openVPN.putExtra("net.openvpn.openvpn.AUTOCONNECT", "true");
        startActivity(openVPN);
    }

Code: Select all

 private void stopVPN() {
        Intent openVPN = new Intent("net.openvpn.openvpn.DISCONNECT");
        openVPN.setPackage("net.openvpn.openvpn");
        openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity");
        openVPN.putExtra("net.openvpn.openvpn.STOP", "true");
        startActivityForResult(openVPN, 0);
Does anybody know what's wrong or missing ?

Any help is very much appreciated.

Bye the way:
I wouldn't mind getting a hint how to start the VPN connection completly in background.
See this post.

fmeyer1
OpenVpn Newbie
Posts: 2
Joined: Thu Feb 15, 2018 7:15 pm

Re: OpenVPN Connect intents changed?

Post by fmeyer1 » Mon Mar 05, 2018 4:25 pm

Thanks for the new info. It works the only issue I have is on disconnect the OpenVPN app stays in the foreground once disconnected. On connect it connects then minimizes perfectly. Is there any way to get the OpenVPN app to close or at least minimize after disconnecting? Thanks.

Composit
OpenVpn Newbie
Posts: 2
Joined: Wed Feb 28, 2018 5:44 pm

Re: OpenVPN Connect intents changed?

Post by Composit » Tue Mar 06, 2018 6:12 pm

@fmeyer1:
did you manage to get it working with Tasker or implemeted in an android app ?
I'm stil searching for the correct method to autoconnect and disconnect programatically with an own android app.
Was perfect before upgrade to 3.0
Since 3.0 I couldn't figure out how to do i.

agefoo
OpenVpn Newbie
Posts: 1
Joined: Thu Jun 06, 2019 12:23 am

Re: OpenVPN Connect intents changed?

Post by agefoo » Thu Jun 06, 2019 12:43 am

@Composit
I know it's been a while however in case it's useful--the following. For my version "OpenVPN Connect 3.0.5" I get better luck when passing the "net.openvpn.openvpn.AUTOCONNECT" and "net.openvpn.openvpn.STOP" extras as booleans instead of strings. The first time you connect and are redirected to the app you might have to accept some sort of permission/disclaimer for autoconnect, but it does autoconnect after the prompt and then in subsequent calls to the code without any prompts. In my setup it runs back to my app after autoconnect. Disconnect happens in the background as desired. In the following my profile in OpenVPN connect is named MYPROFILENAME however in my app I prepend PC and a space before the name which corresponds with the app section.

Code: Select all

	Intent openVPN = new Intent("net.openvpn.openvpn.CONNECT");
        openVPN.setPackage("net.openvpn.openvpn");
        openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity");
        openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "PC MYPROFILENAME ");
        openVPN.putExtra("net.openvpn.openvpn.AUTOCONNECT", true);
        openVPN.putExtra("net.openvpn.openvpn.APP_SECTION", "PC");

        if (openVPN.resolveActivity(getActivity().getPackageManager()) != null) {
		startActivity(openVPN);
        }

Code: Select all

	Intent openVPN = new Intent("net.openvpn.openvpn.DISCONNECT");
        openVPN.setPackage("net.openvpn.openvpn");
        openVPN.setClassName("net.openvpn.openvpn", "net.openvpn.unified.MainActivity");
        openVPN.putExtra("net.openvpn.openvpn.STOP", true);
        if (openVPN.resolveActivity(getActivity().getPackageManager()) != null) {
		startActivityForResult(openVPN, 0);
	}
        

Post Reply