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

internal.flushLog: Flush RPC: service bridge returned HTTP 400 ("App Engine APIs over the Service Bridge are disabled.\nIf they are required, enable them by setting the following to your app.yaml:\n\nbeta_settings:\n enable_app_engine_apis: true\n") #82

Closed
githubwua opened this issue Nov 28, 2017 · 9 comments

Comments

@githubwua
Copy link

The following error for GAE Go Flexible is logged every second:

internal.flushLog: Flush RPC: service bridge returned HTTP 400 ("App Engine APIs over the Service Bridge are disabled.\nIf they are required, enable them by setting the following to your app.yaml:\n\nbeta_settings:\n enable_app_engine_apis: true\n")

The error is coming from:

https://github.com/GoogleCloudPlatform/appengine-sidecars-docker/blob/master/api_proxy/proxy.go#L15

Please note that app.yaml is no longer using any custom runtime:

runtime: go
api_version: go1.8
env: flexible

So, it should stop generating the logs above. Can we please stop logging the above message?

@cnbuff410
Copy link

I'm getting this error all the time as well

@mblasi
Copy link

mblasi commented Dec 24, 2017

Hi! Any update on this?

I migrated from standard GAE to flexible environment, and faced this issue when trying to do a POST request to a resource outside my app.

Regards,
Matías.

@Cynocracy
Copy link

Hi (and apologies for the late response :)),

This error should only occur when you're attempting to make requests over the compatibility service bridge (this would occur only if you're making HTTP requests to appengine.googleapis.internal). If that's the case, it's likely a library you use (or the runtime itself) is making these requests.

Do you have a repro? It'd be useful to help pin down what could be making these requests on our end.

@mblasi
Copy link

mblasi commented Jan 3, 2018

Thank you Cynocracy!

Here is the code I'm trying to run:

`
func Mp(c *gin.Context) {
ctx := trace.StartSpan(c, "mp.callback")
defer trace.EndSpan(ctx)

defer logger.Flush()

b := bytes.NewBuffer(make([]byte, 0))
reader := io.TeeReader(c.Request.Body, b)

var mpAuth MPAuth
if err := json.NewDecoder(reader).Decode(&mpAuth); err != nil {
	respondWithError(http.StatusInternalServerError, "Couldn't decode token", err, c)
}

c.Request.Body = ioutil.NopCloser(b)

data := url.Values{}
data.Set("client_secret", "TEST-123456789")
data.Add("grant_type", "authorization_code")
data.Add("code", mpAuth.Code)
data.Add("redirect_uri", mpAuth.RedirectUri)

method, err := http.NewRequest(http.MethodPost, "https://api.mercadopago.com/oauth/token", bytes.NewBufferString(data.Encode()))

if err != nil {
	respondWithError(http.StatusInternalServerError, "Error creating MP Post method: ", err, c)
}

method.Header.Add("accept", "application/json")
//method.Header.Add("content-type", "application/x-www-form-urlencoded")
method.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
method.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))

client := urlfetch.Client(appengine.BackgroundContext())

resp, err := client.Do(method)

if err != nil {
	respondWithError(http.StatusInternalServerError, "Error retrieving MP token", err, c)
} else if resp == nil {
	respondWithError(http.StatusInternalServerError, "Response vacío", errors.New(""), c)
} else {

	defer resp.Body.Close()
	response, _ := ioutil.ReadAll(resp.Body)

	var dat map[string]interface{}
	if err := json.Unmarshal(response, &dat); err != nil {
		respondWithError(http.StatusInternalServerError, "Error unmarshaling data: ", err, c)
	}

	c.JSON(http.StatusOK, dat)
}

}
`

I get the error from the client.Do(method) line.

I dont know if it is the case you pointed out. The real thing is I need to make a post to an external resource... it is an external system implementing oauth2.

Please, let me know if it is enough for you.

Best regards,
Matías.

@mblasi
Copy link

mblasi commented Jan 3, 2018

I also created this issue in the public tracker: https://issuetracker.google.com/u/2/issues/71050584

@Cynocracy
Copy link

Ah, I see the issue:

URLFetch is itself a compatibility API, you should be able to make HTTP requests normally using something idiomatic in the language. For go, I suppose that means the http package https://golang.org/pkg/net/http/

The main differences between Flex and Standard is the lack of these APIs, as well as an easier access to 'external' resources, so it makes sense that there'd be some confusion here. If there are any docs you think should be updated, feel free to link them and I can try to get someone to take a look :)

@mblasi
Copy link

mblasi commented Jan 4, 2018

Thank you very much Cynocracy!
I'll be working on that then...
Regarding the documentation, in my humble opinion it is little confusing about standard and flexible differences, for example, this page: https://cloud.google.com/appengine/docs/flexible/go/migrating says:

URL Fetch

The flexible environment has no sandbox restrictions, so you can use any HTTP library.

In the other hand, this page: https://cloud.google.com/appengine/docs/flexible/go/flexible-for-standard-users says:

Accessing external services

In the standard environment, your application typically accesses services such as Cloud Datastore via the built-in google.appengine APIs. However, in the flexible environment, these APIs are no longer available. Instead, use the Google Cloud client libraries. These client libraries work everywhere, which means that your application is more portable. If needed, applications that run in the flexible environment can usually run on Kubernetes Engine or Compute Engine without heavy modification.

Anyhow, now, it is more clear for me!

I appreciate your support and, I'd like to take advantage of this thread to ask you about one more confusions between standard and flexible flavors: it is about the tracing mechanism.

I started a couple of threads in gce-discussion forum:

Main thread: https://groups.google.com/forum/#!topic/gce-discussion/1INCUtvc300
Two smaller questions:

The main thread, despite of it is working for me now, it focuses on the confusing documentation, pleaste take a look on my posts.
I'm still waiting for a clearer documentation about stackdriver an app engine...

Thanks again!
Matías.

@patthehuman
Copy link

What is the status of this? These errors just started flooding my logs. Is this whats causing my server to lag horribly?

@Sanrag
Copy link
Contributor

Sanrag commented Apr 29, 2020

The api_proxy sidecar has now been deleted.

@Sanrag Sanrag closed this as completed Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants