TableauSDK proxy settings - java

We are using TableauSDK (Java) to publish extract into Tableau Server.
Our connection to Tableau server is via proxy. So we just set the java system properties https.proxyHost, https.proxyPort, http.proxyHost and http.proxyPort.
But it seems the proxy settings done in above java system properties does not take effect. Please help us to configure proxy settings in TableauSDK (Java)

The Tableau SDK uses a native library under the hood, which integrates with the Java SDK using JNI.
The native library respects the standard environment variables for proxy configuration, http_proxy and https_proxy. On a Linux, or Mac system, you can simply export these environment variables:
export http_proxy="http://my.proxy.server:3128"
export https_proxy="http://my.proxy.server:3128"
java -jar my-application.jar
If you use a proxy server which requires authentication, the SDK exposes a method to set the username and password:
ServerAPI.initialize();
ServerConnection serverConnection = new ServerConnection();
serverConnection.setProxyCredentials("user", "pass");
serverConnection.connect("https://tableau.url", "user", "password", "siteName");
serverConnection.publish("/path/to/extract", "projectName", "dataSourceName", true); // Overwrite Existing
I suspect this works pretty similarly using the Python SDK.

Related

Proxy settings for Big Query Java client

I am writing a Java application that interacts with the Big Query APIs and which will also run in a docker container. I need help in setting up http and https for my application. I am not sure whether specifying only environment variables for docker container is sufficient or only setting the proxy in java code is required or both and how can I do the same.
Thanks in Advance
There are multiple options to achieve this. The cleanest way is to tell the JVM to use system proxies and define the proxy as environment variables for your Docker container. All options are described below.
Option 1: Setting the proxy directly in Java
You can define the proxy directly in your code using System.setProperty(String, String):
System.setProperty("http.proxyHost", "proxy.example.com");
System.setProperty("http.proxyPort", "8080");
Note that the proxy is hardcoded. This solution only works if the proxy stays the same for all environments (local development, deployment on server / cloud).
Option 2: Sepcifying the proxy when invoking the JVM
You can set the proxy as command line parameters when invoking the VM. You don't need additional configurations in your code.
java -Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=8080 YourApplication
You can also use environment variables here, if you have them set. That way the proxy settings could dynamically change depending on the environment.
Option 3: Using system proxies
The third option is to tell the JVM to use the configured system proxies (which you can do as described below). This is again achieved by setting a command line parameter.
java -Djava.net.useSystemProxies=true YourApplication
Setting the system proxy
To set the system proxies for Docker, you again have two options.
Option a: Use environment variables
You can use environment variables directly in your Dockerfile:
ENV HTTP_PROXY "http://proxy.example.com:8080"
Or you can specify the environment variables in your docker run command:
docker run --env HTTP_PROXY="http://proxy.example.com:8080" your-container
Option b: Configuring the Docker client
On the Docker client, create or edit the file ~/.docker/config.json and set the proxy:
{
"proxies":
{
"default":
{
"httpProxy": "http://proxy.example.com:8080"
}
}
}
This option only configures your local client, you would need to configure other environments accordingly.

How to connect opc kepware server through a Java program, without the username and the password?

I am trying to connect opc kepware server through a Java program, I want to know what jar files can be used to connect to KepwareserverEx.V5 and what is the code without the use of password and username.
I have referenced http://www.opcconnect.com/uakit.php, and https://github.com/digitalpetri/ua-server-sdk, but it doesn't have anything that doesn't connect without a username and a pawssword. I have a program in vb that connects to kepware using Interop.OPCAutomation.dll file and uses the code:
ConnectedOPCServer = New OPCAutomation.OPCServer
ConnectedOPCServer.Connect("Kepware.KEPServerEX.V5", "")
ConnectedGroup = ConnectedOPCServer.OPCGroups.Add("MPM Group")
ConnectedGroup.UpdateRate = 1000
ConnectedGroup.IsSubscribed = True
ConnectedGroup.IsActive = True
I want to write Java code in a similar way. Searched through the internet to see various examples, but none have the above connection without a username and password not being specified.
First of all, I assume that you have created an "anonymous" and "SecurityPolicy.None" endpoint on KepServerEX.
You refer to digitalpetri's old and server SDK. The new project is called "Milo". I can recommend you take a look at the Milo project's client SDK examples using this link. There is an application of anonymous identity and none security policy.
In terms of jar, you can either build your client-sdk (see example here) or directly download the client-sdk jar from Maven Central.
NB Milo is considered to be in incubation. That is to say, it is not mature yet. Be careful using it in production systems.
Yes that's right. The security policy is none on the KepwareServerEX. I made some permission changes on the server where Kepware exists, so that my localhost computer would be able to talk to the Kepware server host. Provided credentials for my localhost, and able to connect.

How to setup AWS Lambda service for a local server

I am trying to setup an application server for AWS Lambda but on a local network so that an application won't have to go out to the internet to execute. I would prefer to use a linux box and my programming environment is Java.
The skill from the echo will execute and then communicate with the local server rather than going out to the internet and communicating with Amazon's application server.
My question is this: How do I setup the application server to handle the skill? I've done the example from Amazon, do I only need to have the linux box run the Java application or is there more to the setup than that? I see there are AMIs (Amazon Machine Images) but can I deploy those locally or are they only for use on the AWS console?
Any insight into this would be great, thank you.
So this is how usual interaction between echo works:
User--->Echo--->Skill--->(Internet)Applicaton server (I'm using Amazon hosted AWS lambda)
I would like to use :
User--->Echo--->Skill--->(LAN)Application server (without ever using the internet).
Currently I have setup echo and a skill but no application server on the LAN. What do I need for the application server? JAWS and something else?
I'm not sure if this question is still relevant or not, but I'm using DEEP Framework to test the code locally and/or deploy it on AWS Lambda. Check this out:
npm install deepify -g
deepify run-lambda --help
run-lambda#1.6.8 - Run Lambda function locally
Usage example: deepify run-lambda path/to/the/lambda -e='{"Name":"John Doe"}'
Arguments:
path: The path to the Lambda (directory of handler itself)
Options:
--event|-e: JSON string used as the Lambda payload
--skip-frontend-build|-f: Skip picking up _build path from the microservices Frontend
--db-server|-l: Local DynamoDB server implementation (ex. LocalDynamo, Dynalite)
--version|-v: Prints command version
--help|-h: Prints command help
Also, you might want consider using the server option:
deepify server --help
server#1.6.9 - Run local development server
Usage example: deepify server path/to/web_app -o
Arguments:
path: The path to the Lambda (directory of handler itself)
Options:
--build-path|-b: The path to the build (in order to pick up config)
--skip-frontend-build|-f: Skip picking up _build path from the microservices Frontend
--skip-backend-build|-s: Skip building backend (dependencies installation in Lambdas and linking aws-sdk)
--skip-build-hook|-h: Skip running build hook (hook.build.js)
--port|-p: Port to listen to
--db-server|-l: Local DynamoDB server implementation (ex. LocalDynamo, Dynalite)
--open-browser|-o: Open browser after the server starts
--version|-v: Prints command version
--help|-h: Prints command help
Disclosure: I am one of the contributors to this framework

Proxy Implementation with WebLogic 11g

I am using WebLogic server 10.x (11g) to deploy and service my applications. However, our production environment consists of a proxy server which is causing troubles if I try to access certain sites.
Therefore, I would love to know if any feasible solution available to resolve this by configuring the proxy server details on our
WebLogic Environment
Application Level - I am using Java to develop my applications
Thanks in advance.
There are two possible ways to aaccomplish this.
Configuring WebLogic Env.
Programatically
Let's look at these.
Proxy Configuration in Application Server
Let's take WebLogic application server to illustrate the desired configuration
Configure WebLogic Server to Enable Proxy
1. Using WebLogic Administration Console
Login into Administration console
Go to Domain -> Environment -> Servers -> Admin Server -> Configuration -> Server Start
Inside Arguments section enter following and save.
-jvmargs -Dhttp.proxySet=true -Dhttp.proxyHost=server_url -Dhttp.proxyPort=port
Restart the WebLogic Server
2. Using WebLogic Startup Scripts
Open WebLogic domain configuration script at
Search for the following phrase "JAVA_OPTIONS"
Enter following details after that.
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dhttp.proxyHost=server_url -Dhttp.proxyPort=port
Save script and start the WebLogic server
Using Programatically
There are several implementations available and let's discuss few approaches which I think would be useful.
Proxy Configuration Using Values
As highlights below you can configure a proxy using programatically defined values inside your application.
System.setProperty("http.proxyHost", "proxy_url");
System.setProperty("http.proxyPort", "port");
Configuration with User Credentials
Sometimes you may need to provide exact credentials to get through proxy server. Here is an implementation which will help you to achieve this.
import java.net.Authenticator;
import java.net.PasswordAuthentication;
public class MyAuthenticator extends Authenticator {
private String username;
private String password;
public MyAuthenticator(String username, String password){
this.username = username;
this.password = password;
}
public PasswordAuthentication getPasswordAuthentication () {
return new PasswordAuthentication (username, password.toCharArray());
}
}
The defined Authenticator class can be used to inject credentials to the proxy configuration as below.
System.setProperty("http.proxyHost", "proxy_url");
System.setProperty("http.proxyPort", "port");
Authenticator.setDefault (new MyAuthenticator("domain_name\\user_name","password"));
In either case you need to implement the usages at program level as given below. Otherwise, proxy communication will not success and end up throwing exceptions.
final URL url = new URL(null, urlString, new sun.net.www.protocol.http.Handler());
To configure WebLogic proxy file is modified setDomainEnv.cmd (Windows) that is located in the bin folder of the domain.
For example for the integrated server is here
C: \ Users \ [YOUT USER NAME] \ AppData \ Roaming \ JDeveloper \ system11.1.1.4.37.59.23 \ DefaultDomain \ bin
The following property must be placed on file with the details of your proxy
#REM Estableciendo proxi
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dhttp.proxySet=true -Dhttp.proxyHost=192.168.101.11 -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=localhost
See the next link
Configure WebLogic Proxi
I had a similar problem in my developer environment running WebLogic 14.1.1.0.0 inside Eclipse IDE. I spend a day finding a working solution to configure a proxy server.
Finally I set the variable EXTRA_JAVA_PROPERTIES in startWebLogic.cmd
set EXTRA_JAVA_PROPERTIES=-Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=3128 -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=3128
here is a tiny JSP page to test, if proxy setting are applied to the JVM:
<html>
<body>
<p><%=System.getProperty("http.proxyHost") %></p>
<p><%=System.getProperty("http.proxyPort") %></p>
<p><%=System.getProperty("https.proxyHost") %></p>
<p><%=System.getProperty("https.proxyPort") %></p>
</body>
</html>
There are solutions I tried, but which DID NOT WORK for me:
Setting EXTRA_JAVA_PROPERTIES in setDomainEnv.cmd as recommended by Oracle [1]
Setting JAVA_OPTIONS in startWebLogic.cmd as recommended by Aviro and Manish Kumar Gupta [2]
Setting Server Start Arguments over Administration Console
[1] Configure Proxy Settings for WebLogic Server
https://docs.oracle.com/cd/E53672_01/doc.111191/e53673/GUID-36A18CFA-55F1-4D19-B371-A6D15EBF2E24.htm
[2] Proxy server configuration for Weblogic Server !!!
https://kumarsoablog.blogspot.com/2016/10/proxy-server-configuration-for-weblogic.html

Java proxy settings

I have global proxy settings made from Java control applet. It takes proxy settings from browser. I need to run a Java application that does not use global proxy settings, it has to use direct connection.
How can I do it with command line arguments?
Did you have a look here: http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html ?
You can set the system properties from the command line: java ... -Dhttp.proxyHost=your-proxy.example.com ...
open java control panel using
javaws -viewer
General-> Network Settings -> direct Connetcion
now direct connection is set

Categories

Resources