Proxy settings for Big Query Java client - java

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.

Related

How to see java logs inside Hyperledger Fabric chaincode?

I am trying to use Fabric whith java shim and I am still searching how to display logs on the peer output ?
I tried this :
peer node start --logging-level DEBUG
also searching to use the logger of the parent class :
private static Log logger = LogFactory.getLog(ChaincodeBase.class);
without success. Cannot see the outputs on the peer
Does anyone has an idea ?
I found myself the solution. It implies to access the Docker image inside the peer and call :
docker logs mycontainersidwhatever
but i think is could be still buggy as I am in DEBUG mode, and I see now only WARN level for the chaincode
When you instantiate a new chaincode, the peer will create a new docker container called dev-(peer name)-(contract name)-(contract version). You can see logs direct in this container.
However, fabric java chaincode uses its own logging configuration, and it uses an environment variable called CORE_CHAINCODE_LOGGING_LEVEL to define the logging level the chaincode will use. Usually, this environment variable is set to 'info' level. You can manually update the value of this variable inside the docker container running the contract, or you can define this variable into the peer, so every contract will the the defined value to it.
In 'fabric-samples\first-network\base\peer-base.yaml' ensure you have the following before you start HLF network, and then spin up the network.
FABRIC_LOGGING_SPEC=DEBUG
This will generate logs in DEBUG mode. Now, in order to see these logs that are generated within docker contaner, we'll have to ask docker for logs, and that can be done using in a terminal window.
docker logs -f <<container-name>>
Use
docker logs container_name
Or inside your docker_compose.yaml, set logging environment
FABRIC_LOGGING_SPEC=DEBUG
Or else,
try setting up in you cli for one time use
export

TableauSDK proxy settings

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.

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

How to get default proxy settings in java program (not applet)?

I've just gone through the web searching how to get system proxy settings. I've found:
System.setProperty("java.net.useSystemProxies", "true");
but it does nothing. I have a proxy settings in my corpo network but the code that shows the proxy list:
ProxySelector.getDefault().select(new URI("http://foo/bar")))
says it's only one proxy "DIRECT". I don't want to provide the proxy settings by hand when it's already done. Is there a way to make JVM to provide proxy settings from OS/browser to the Java program (not applet)?
Ok,I think I got it: my browser proxy is set up by some script, defined in:
Internet Properties/Connections/LAN Settings/Use automatic
configuration script
Probably, that's why Java cannot list proxy properly, even it's used in the browser. Sad, that JVM cannot parse the script and provide these settings...
You have to set the property:
System.setProperty("java.net.useSystemProxies", "true");
in the main method, otherwise it get no effect, then call the getDefault() as you described.

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