Java Google Cloud App Engine 上的 11 个应用程序 运行 注册调试对象时出现 401 错误

Java 11 app running on Google Cloud App Engine fails with 401 error for registering debuggee

我在 Google Cloud App Engine 上部署了 Java 11 个应用程序,应用程序 运行 很好,我可以在浏览器中看到主页,但是当应用程序尝试调用 Microsoft Graph API(使用 Microsoft Graph SDK 执行 HTTP 调用),我遇到运行时故障。

故障与 Google 调试器有关,但我什至没有启用调试器。我发现 Google 构建容器镜像时默认启用调试器的信息。我有两个选择 - 要么找出调试器出现 401 错误的原因,然后正确配置调试器,要么完全禁用调试器。

我试图查找有关如何为容器映像生成禁用 Google 调试器的信息,但没有找到任何有用的信息。我还尝试查找有关如何为 App Engine 正确配置调试器的信息,但也无法找到完整的工作说明。有人知道我需要在 App Engine 上配置什么来绕过这个错误吗:

    java.io.IOException: Server returned HTTP response code: 401 for URL: https://clouddebugger.googleapis.com/v2/controller/debuggees/register

at com.google.devtools.cdbg.debuglets.java.GcpHubClient.registerDebuggee

假设您的 Java 应用在 App Engine 标准环境中并使用捆绑服务,那么您仍在使用 appengine-web.xml file for app configuration. As stated in GAE standard Issuing HTTP(S) Request 文档:

URL Fetch will handle all outbound requests and cause requests that you send to your VPC network or the client libraries to fail. If any of these scenarios apply to you, make sure that the url-stream-handler field in your configuration is not set to urlfetch.

此场景包括 Google Java 的 Cloud Debugger Client,因此出现 HTTP 错误。作为解决方法,您可以在 appengine-web.xml 文件中省略以下行:

<url-stream-handler>urlfetch</url-stream-handler>