ccnnde/react-native-simple-openvpn

opvnString does not work

Closed this issue · 4 comments

The problem is with reading the .ovpn file, the VPN works, but with ovpnString, it does not work :

  async function connectVpn() {
    updateState(VPN_STATES.CONNECTING);
    try {
      await RNSimpleOpenvpn.connect({
        remoteAddress: 'server',
        //ovpnFileName: 'client',
        //assetsPath: '',
        ovpnString: ovpnConfig ,
        notificationTitle: 'VPN',
        compatMode: RNSimpleOpenvpn.CompatMode.OVPN_TWO_THREE_PEER,
        providerBundleIdentifier: 'com.your.network.extension.bundle.id',
        localizedDescription: 'TestRNSimpleOvpn',
      });
    } catch (error) {
      console.error(error);
      updateState(VPN_STATES.DISCONNECTED);
    }
  }

What should I do ?
I am using the following to read ovpnConfig :
import { ovpnConfig } from './Config';

ccnnde commented

Please check if the content of your ovpnString is consistent with the configuration file.

Thanks for the quick response.
Even if I put .ovpn content as a string and give it to ovpnString, it does not work. Unfortunately, console.error(error) does not show any log, so I do not know the source of the problem.
I am using Ubuntu, and I am installing it on Android.
Installing APK 'app-debug.apk' on 'Pixel_2_API_30(AVD) - 11' for :app:debug
I am sharing package.json content:
{ "name": "TESTAPP", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@react-native-async-storage/async-storage": "^1.18.2", "react": "18.2.0", "react-native": "0.72.0", "react-native-circular-progress": "^1.3.9", "react-native-simple-openvpn": "^2.1.0", "react-native-svg": "^13.9.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.22.5", "@babel/runtime": "^7.20.0", "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.6", "@tsconfig/react-native": "^3.0.0", "@types/metro-config": "^0.76.3", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.76.5", "prettier": "^2.4.1", "react-test-renderer": "18.2.0", "typescript": "4.8.4" }, "engines": { "node": ">=16" } }
Bug

After investigating, I noticed unnecessary tabs in the .ovpn file I copied.
The string content should be identical to the .ovpn file format, tabs, etc.
@ccnnde Please change the log in a way if the ovpnString is not correct, it throws an error. Otherwise, debugging is a hassle.
I am closing the issue.

ccnnde commented

ok, but in reality, the logs originate from a third-party library