citrix / citrix/citrix-mam-sdk-sample-browser-app-android-java
MicroVpnSDK does not open the tunnel in prduction
- Dominant language
- Java
- Stars
- 5
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Integrated MAM and Micro VPN SDKs in to my app, but when we uploaded the build to securehub app is not able to exchange request response from Backen port, though the tunnel started call back received at the app launch still none of the APIs were successfull,
Initiated and started the tunnel at the launch of an app in my case in SplashScreen
if (mvpnHandler == null) {
mvpnHandler = new TunnelHandler(this);
}
Log.i(TAG, "Before calling startTunnel()");
if (VpnUtil.startTunnel(this, mvpnHandler)) {
Toast.makeText(this, "Initiated Tunnel", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Tunnel Failed to Start!!!", Toast.LENGTH_LONG).show();
}
Callback and establish URL connection
@Override
public void onTunnelStarted() {
showToast("Tunnel Started Successfully!!!");
new UrlConnectionAsyncTask(SplashActivity.this).execute(getIntent().getStringExtra(ApiUtils.BASE_URL));
}
@Override
public void onError(boolean isSessionExpired) {
showToast("Tunnel Failed to Start!!!");
}
Async Task on URL connection establish
private static class UrlConnectionAsyncTask extends AsyncTask {
private WeakReference reference;
private UrlConnectionAsyncTask(SplashActivity activity) {
reference = new WeakReference<>(activity);
}
private SplashActivity getActivity() {
if (reference != null) {
return reference.get();
}
return null;
}
@Override
protected String doInBackground(String... strUrl) {
StringBuilder response = new StringBuilder();
Activity activity = getActivity();
try {
URL url = new URL(strUrl[0]);
HttpURLConnection conn;
if (MicroVPNSDK.isNetworkTunnelRunning(activity)) {
conn = (HttpURLConnection) MicroVPNSDK.createURLConnection(activity, url);
} else {
conn = (HttpURLConnection) url.openConnection();
}
int responseCode = conn.getResponseCode();
InputStream inputStream;
if (200 <= responseCode && responseCode <= 299) {
inputStream = conn.getInputStream();
} else {
inputStream = conn.getErrorStream();
}
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
String currentLine;
while ((currentLine = in.readLine()) != null) {
response.append(currentLine);
}
in.close();
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
return response.toString();
}
@Override
protected void onPostExecute(String responseHtml) {
}
}
App receives a callback says Tunnel started but API request failed, able to generate MDX
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.