googleads / googleads-java-lib

Google Ad Manager SOAP API Client Library for Java
Apache License 2.0
226 stars 360 forks source link

Exception when trying to change budget #201

Closed aylon11 closed 10 months ago

aylon11 commented 4 years ago

I have a client who is trying to make changes to a budget from their production servers using adwords API, but get the following error (attached is the full error they have sent me):

com.ppcservice.service.AdWordsAPIService - >>>>> Exception occurred in addBudget= javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

From my understanding, this error occurs when you try to make an HTTPS request to an HTTP server, but i can not understand why they are receiving it here.

here is the code they use:

` try { LOGGER.info(">>>>> Start of " + Thread.currentThread().getStackTrace()[1].getMethodName());

        AdWordsServicesInterface adWordsServices = AdWordsServices.getInstance();

        // Get the BudgetService.

        BudgetServiceInterface budgetService = adWordsServices.get(getAdWordsSession(), BudgetServiceInterface.class);

        // Create a budget, which can be shared by multiple campaigns.

        Budget budget = new Budget();

        budget.setName(campaignUI.getName());

        Money budgetAmount = new Money();

        LOGGER.info(">>>>> Budget amount= " + campaignUI.getAmount() * 1000000);

        budgetAmount.setMicroAmount((campaignUI.getAmount().longValue()) * 1000000);

        budget.setAmount(budgetAmount);

        budget.setIsExplicitlyShared(false);

        budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);

        BudgetOperation budgetOperation = new BudgetOperation();

        budgetOperation.setOperand(budget);

        budgetOperation.setOperator(Operator.ADD);

        // Add the budget

        Long budgetId = budgetService.mutate(new BudgetOperation[] { budgetOperation }).getValue(0).getBudgetId();

        return campaignUI;

        } catch(ApiException ae) {

              LOGGER.error(">>>>> ApiException occurred in addBudget= " + ae);

              return null;

        } catch(Exception e) {

              LOGGER.error(">>>>> Exception occurred in addBudget= " + e);

              return null;

`

I have attached the SOAP request and response and the full error log.

Any ideas on why that happens and how to avoid this?

Thanks error.txt soap.txt

nwbirnie commented 4 years ago

Is it possible that the client's network requires them to make HTTP(S) connections via a proxy? If so then they should configure the proxy as shown here.

JNivedita commented 4 years ago

We have tried these proxy settings but still we are facing the same issue. com.ppcservice.service.AdWordsAPIService - >>>>> Exception occurred in addBudget= javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

Seems like its a problem with the the axis library (axis 1.4 lib) interaction with proxy. Is Google Adwords API compatible with Axis-2 lib (1.7.9 version)? Can you please suggest on this.

nwbirnie commented 4 years ago

We don't support Axis 2 for the AdWords API - reason being that this is a nontrivial migration, and we're investing in Google Ads API as the replacement to AWAPI. This is based on gRPC + REST rather than SOAP, so has the advantage of being a more modern tech stack.

However, I'm not sure that this is a problem with the library itself, since we have extensively tested this with many other users. Could you get some information from the client about their network environment please? Specifically, it would be helpful to understand if their network enforces HTTPS proxies, if the proxy requires any authentication, or any other unusual network setup such as load balancers.

JNivedita commented 4 years ago

Thanks for the quick turnaround.

Regarding the issue, we are using HTTP forward proxy which is configured in app via JVM args -Dhttps.proxyHost=fwpproxy.service -Dhttps.proxyPort=8080

Forward proxy is needed in this environment. This forward proxy is an apache httpd instance. It does not have SSL configured and does not require authentication

We are able to make other http requests including Adwords OAuth2 via forward proxy without any issues from this application. We are facing this issue where the calls are happening via axis.

We see 400 requests in our proxy servers w.r.t this calls. Below are the detailed axis logs: 2020-08-20 09:04:34,894 DEBUG main org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(isNull00) 2020-08-20 09:04:34,894 DEBUG main org.apache.axis.components.net.DefaultSocketFactory - is tunnelInputStream null? false 2020-08-20 09:04:34,901 DEBUG main org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(setupTunnel00) 2020-08-20 09:04:34,901 DEBUG main org.apache.axis.components.net.DefaultSocketFactory - Set up SSL tunnelling through fwpproxy.service:8080 2020-08-20 09:04:34,908 DEBUG main org.apache.axis.transport.http.HTTPSender - javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? 2020-08-20 09:04:34,911 DEBUG main org.apache.axis.SOAPPart - Enter: SOAPPart ctor(FORM_FAULT) 2020-08-20 09:04:34,911 DEBUG main org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(setMsgForm) 2020-08-20 09:04:34,911 DEBUG main org.apache.axis.SOAPPart - Setting current message form to: FORM_FAULT (currentMessage is now org.apache.axis.AxisFault) 2020-08-20 09:04:34,911 DEBUG main org.apache.axis.SOAPPart - Exit: SOAPPart ctor() 2020-08-20 09:04:34,912 DEBUG main org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(toAxisFault00) 2020-08-20 09:04:34,912 DEBUG main org.apache.axis.enterprise - Mapping Exception to AxisFault AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:710) at sun.security.ssl.InputRecord.read(InputRecord.java:527) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186) at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191) at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

Can you please check and suggest on what can be done to address this?

nwbirnie commented 4 years ago

Could you try specifying the proxy as a HTTP (not HTTPS) proxy please? This would be:

-Dhttp.proxyHost=fwpproxy.service -Dhttp.proxyPort=8080

JNivedita commented 4 years ago

We have tried that too. If we dont have https proxy, OAuth calls are not working. We were getting Connection timed out exceptions for Oauth.

Tried having both http and https proxy but no luck.

nwbirnie commented 4 years ago

Could you try them both at the same time? It looks like Axis (which is used for ads API calls) explicitly checks the HTTP properties, rather than HTTPS.

JNivedita commented 4 years ago

We tried having both http and https proxy conf in JVM args at the same time but didnt work. -Dhttp.proxyHost=fwpproxy.service -Dhttp.proxyPort=8080 -Dhttps.proxyHost=fwpproxy.service -Dhttps.proxyPort=8080

Alternatively we even tried having System and Axis level HTTP proxy settings for this axis calls explicitly. Still no luck.

System.setProperty("http.proxyHost", "fwpproxy.service"); System.setProperty("http.proxyPort", "8080");

AxisProperties.setProperty("http.proxyHost", "fwpproxy.service"); AxisProperties.setProperty("http.proxyPort", "8080");

nwbirnie commented 4 years ago

So from the error you're receiving (Unrecognized SSL message, plaintext connection), it appears that your proxy tunnels HTTPS over HTTP. So the correct configuration here should be http.proxyHost and http.proxyPort. Could you provide the stacktrace from running with these two parameters only please?

christopherseeley commented 10 months ago

Closing as stale. AdWords API has been turned down and replaced by the Google Ads API.