How to use proxy in google-ads-php and nginx grpc?

64 views
Skip to first unread message

bingcool huang

unread,
Dec 7, 2020, 4:38:41 AM12/7/20
to AdWords API and Google Ads API Forum
Hello, Google Ads Groups

Because Online server can not connect google ,so we need to make a proxy in google-ads-php with nginx grpc module,  this is my nginx config:
server {
listen 9703 http2; #监听端口
   location / {
         grpc_pass grpcs://googleads.googleapis.com:443;
          grpc_connect_timeout 300;
          grpc_read_timeout 300;
         grpc_send_timeout 300;
    }
}

then this is php setting:
$googleAdsClient = (new GoogleAdsClientBuilder())
->from($configuration)
->withOAuth2Credential($oAuth2Credential)
->withProxy('http://47.52.203.169:9703')
->build();

nginx access_log show:

61.141.64.196 - - [07/Dec/2020:17:11:17 +0800] "CONNECT googleads.googleapis.com:443 HTTP/1.0" 400 163 "-" "-"

but I can not test successful,   So how can I do it, think you very much!

Google Ads API Forum Advisor Prod

unread,
Dec 7, 2020, 2:08:20 PM12/7/20
to bingco...@gmail.com, adwor...@googlegroups.com
Hello,

Thank you for reaching out. Can you please confirm if you have set the google_ads_php.ini file as specified in this PHP client library guide?

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q28nnB2:ref

bingcool huang

unread,
Dec 7, 2020, 9:42:24 PM12/7/20
to AdWords API and Google Ads API Forum

Hi,
I  confirm google_ads_php.ini had been setted,as example:

[CONNECTION]
; Optional proxy settings to be used by requests.
; If you don't have username and password, just specify host and port.
proxy = "http://47.52.203.169:9703"


but when I test, throw error message as example:

[2020-12-08T10:36:13.749750+08:00] google-ads.WARNING: Request made: Host: "googleads.googleapis.com", Method: "/google.ads.googleads.v5.services.KeywordPlanIdeaService/GenerateKeywordIdeas", CustomerId: 6059927370, RequestId: "", IsFault: 1, FaultMessage: "None"
[2020-12-08T10:36:13.750358+08:00] google-ads.NOTICE: Request
-------
Method Name: /google.ads.googleads.v5.services.KeywordPlanIdeaService/GenerateKeywordIdeas
Headers: {
    "x-goog-api-client": "gl-php\/7.3.6 gapic\/ gax\/1.6.0 grpc\/1.33.1",
    "x-goog-request-params": "customer_id=6059927370",
    "developer-token": "REDACTED",
    "login-customer-id": "1904659319"
}
Request: {"customerId":"6059927370","language":"languageConstants/1000","keywordPlanNetwork":"GOOGLE_SEARCH_AND_PARTNERS","keywordSeed":{"keywords":["crm1"]}}

Response
-------
Headers: []

Fault
-------
Status code: 14
Details: failed to connect to all addresses
Failure: {}

How can I do It?   think you very much!

Google Ads API Forum Advisor Prod

unread,
Dec 9, 2020, 12:05:29 PM12/9/20
to bingco...@gmail.com, adwor...@googlegroups.com
Hello,

Thank you for providing those additional details. Allow me to bring this issue to our team and investigate further. We will provide an update as soon as we can.

Thanks,
Reply all
Reply to author
Forward
0 new messages