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

Proxy support? #1247

Open
bootstraponline opened this issue Mar 25, 2019 · 2 comments
Open

Proxy support? #1247

bootstraponline opened this issue Mar 25, 2019 · 2 comments
Labels
priority: p4 type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@bootstraponline
Copy link

I'm using the Firebase Test Lab Java client which uses google-api-java-client under the hood. A bug report came in that the API calls aren't respecting proxies. When using the gcloud CLI, proxy support is automatically detected with no end user configuration. Is it possible to achive something similar with google-api-java-client?

Environment details

  • OS: macOS Mojave 10.14.3
  • Java version: 1.8.0_192
  • google-api-java-client version: google-api-client-1.28.0.jar

Steps to reproduce

import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
import com.google.api.client.googleapis.util.Utils
import com.google.api.services.toolresults.ToolResults
import com.google.auth.http.HttpCredentialsAdapter
import com.google.auth.oauth2.UserCredentials
import java.io.FileInputStream
import java.io.ObjectInputStream
import java.nio.file.Paths

fun main() {
    val httpCredential = HttpCredentialsAdapter(ServiceAccountCredentials.getApplicationDefault().createScoped(listOf("https://www.googleapis.com/auth/cloud-platform")))
    val httpTransport = GoogleNetHttpTransport.newTrustedTransport()
    val jsonFactory = Utils.getDefaultJsonFactory()

    val service = ToolResults.Builder(httpTransport, jsonFactory, httpCredential).setApplicationName("test").build()
    service.Projects().initializeSettings("1234").execute()
}

Stacktrace

Exception in thread "main" java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259)
    at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:113)
    at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1040)
    at com.google.auth.oauth2.UserCredentials.refreshAccessToken(UserCredentials.java:227)
    at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:181)
    at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:167)
    at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96)
    at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:397)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:515)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:448)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
    at DebugKt.main(Debug.kt:22)
    at DebugKt.main(Debug.kt)

External references such as API reference guides used

@leinardi
Copy link

I'm currently evaluating for the company I work for if it would make sense to run our CI's Espresso tests using Firebase Test Lab instead of using the standard Android Emulator on our local build servers.
This issue is blocking us because FTL doesn't provide any sharding feature and Flank is the best solution out there but cannot be used because of the missing proxy support of google-api-client.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Mar 26, 2019
@sduskis sduskis added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 11, 2019
@HarryEuro
Copy link

I'm also having similar issues because i'm behind a corporate proxy with a self signed certificate. The proxy url and port can be specified with VM options (-Dhttp.proxyHost=... -Dhttp.proxyPort=...).

The big problem is the self signed certificate. The google-api-java-client uses it's own Java KeyStore (src/main/resources/com/google/api/client/googleapis/google.jks) and not the official from Java ($JAVA_HOME/jre/lib/security/cacerts). So our self signed certificate cannot be verified and the request will fail.

Writing a custom pluggable transport is also not possible since i'm not using the google-api-java-client directly. I'm using Apache Beam v2.16.0 which uses google-api-java-client 1.27.0 to stage files. The workaround that i come up with was to add our self signed certificate to the google.jks file located in google-api-client-1.27.0.jar which is of course not a good solution. But then everything worked behind our proxy.
Also the Magnitude Simba drivers for BigQuery are not working for the same reason behind our proxy. They are needed so BigQuery can be used with JetBrains DataGrip.

The same problems are also described in #1114 but with no solution. So is anyone working on this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p4 type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

6 participants