Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with creating insecure channel for enterprise customers #17

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The third version number (`Z` out of `X.Y.Z`) is used by this library for any in

## Getting started

### Constructing the Stub
Construct the *Stub* object using which you'll access all the Clarifai API functionality:

```java
Expand All @@ -77,6 +78,23 @@ V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.get
>
> We only recommend them in special cases.

### Additional Steps for Enterprise Users

If you're using the SaaS platform at Clarifai.com, you're good - there is nothing more you need to do. If you're using a custom install of the Clarifai platform as an enterprise user, there are several environmental variables that should be set as necessary to communicate to the client where it should reach out to for the connection with the appropriate platform.

```bash
# For REST calls, you want to set the private IP address of the platform install
export CLARIFAI_API_BASE=<PLATFORM IP ADDRESS>

# For gRPC calls, you want to set the private IP address of the platform install
# You may optionally also want to set the gRPC accessible port if you are planning to
# use the insecure channel.

export CLARIFAI_GRPC_BASE=<PLATFORM IP ADDRESS>
export CLARIFAI_GRPC_PORT=<PLATFORM gRPC PORT>
```

## Example Predict Call

Predict concepts in an image:

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/clarifai/channel/ClarifaiChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ public ManagedChannel getGrpcChannel(String base) {

public ManagedChannel getInsecureGrpcChannel() {
marshallerType = MarshallerType.PROTO;
String base = System.getenv("CLARIFAI_GRPC_BASE");
if (base == null)
base = "api.clarifai.com";
String port = System.getenv("CLARIFAI_GRPC_PORT");
if (port == null)
port = "18080";

return NettyChannelBuilder
.forAddress("api-grpc.clarifai.com", 18080)
.forAddress(base, Integer.parseInt(port))
.usePlaintext()
.build();
}
Expand Down