Google appengine cloud tasks alpha handler php 404错误

时间:2017-12-09 13:56:13

标签: google-app-engine go

当我将任务发送到任务队列时,它会一直失败并在日志中显示http 404(未找到)错误。

该项目已针对灵活的云端任务alpha列入白名单。

我可以将HTTP post请求发送到/ endpointpath& / tasks / worker本地没有任何错误。

端点正常工作,并将任务添加到任务队列。

 13:37:41.300 POST 200 0 B 422 ms curl/7.54.0 /endpointspath?key=keyremoved 0.0.0.0 - "POST endpointspath?key=keyremoved" 200 undefined "-" "curl/7.54.0"

该应用程序作为默认服务运行。

app.go main func:

func main() {
    r := mux.NewRouter()

    r.HandleFunc("/", handler)

    r.HandleFunc("/_ah/health", healthCheckHandler)

    // Task handlers

    r.Path("/tasks/worker").Methods("POST", "GET", "PUT").HandlerFunc(workerTaskHandler)

    // Endpoints

    r.Path("/endpointpath").Methods("POST").HandlerFunc(searchHandler)

    http.Handle("/", r)

    port := 8080
    if portStr := os.Getenv("PORT"); portStr != "" {
        port, _ = strconv.Atoi(portStr)
    }
    log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
}

缩写为app.yaml:

runtime: go
env: flex

handlers:
- url: /tasks/.*
  script: _go_app
- url: /.*
  script: _go_app

当队列向工作人员发送请求时记录HTTP 404响应:

10.0.0.1 - "POST /tasks/worker" 404 200 "-" "AppEngine-Google; (+http://code.google.com/appengine)"
Expand all | Collapse all {
 httpRequest: {
  latency:  "0s"    
  referer:  "-"    
  remoteIp:  "10.0.0.1"    
  requestMethod:  "POST"    
  requestUrl:  "/tasks/worker"    
  responseSize:  "200"    
  status:  404    
  userAgent:  "AppEngine-Google; (+http://code.google.com/appengine)"    
 }
 insertId:  "......."   
 jsonPayload: {
  appLatencySeconds:  "-"    
  latencySeconds:  "0.000"    
  time:  null    
  trace:  "......."    
 }
 labels: {
  appengine.googleapis.com/instance_name:  "......"    
  appengine.googleapis.com/trace_id:  "......."    
  compute.googleapis.com/resource_id:  "......."    
  compute.googleapis.com/resource_name:  "......"    
  compute.googleapis.com/zone:  "us-central1-b"    
 }
 logName:  "projects/projectname/logs/appengine.googleapis.com%2Fnginx.request"   
 receiveTimestamp:  "2017-12-09T10:56:14.794726383Z"   
 resource: {
  labels: {
   module_id:  "default"     
   project_id:  "projectname"     
   version_id:  "....."     
  }
  type:  "gae_app"    
 }
 timestamp:  "2017-12-09T10:56:10.301Z"   
}

我最接近GAE来找到任务/工人网址是通过在app.yaml中设置login:admin(即使tho flex也不使用它进行身份验证)。这将返回403未经授权的错误。

handlers:
- url: /tasks/.*
  script: _go_app
  login: admin

以下是日志中的403响应

{
 httpRequest: {
  latency:  "0s"    
  referer:  "-"    
  remoteIp:  "10.0.0.1"    
  requestMethod:  "POST"    
  requestUrl:  "/tasks/worker"    
  responseSize:  "162"    
  status:  403    
  userAgent:  "AppEngine-Google; (+http://code.google.com/appengine)"    
 }
 insertId:  "....."   
 jsonPayload: {
  appLatencySeconds:  "-"    
  latencySeconds:  "0.000"    
  time:  null    
  trace:  "....."    
 }
 labels: {
  appengine.googleapis.com/instance_name:  "...."    
  appengine.googleapis.com/trace_id:  "...."    
  compute.googleapis.com/resource_id:  "...."    
  compute.googleapis.com/resource_name:  "....."    
  compute.googleapis.com/zone:  "us-central1-b"    
 }
 logName:  "projects/projectname/logs/appengine.googleapis.com%2Fnginx.request"   
 receiveTimestamp:  "2017-12-09T13:35:59.986118082Z"   
 resource: {
  labels: {
   module_id:  "default"     
   project_id:  "projectname"     
   version_id:  "....."     
  }
  type:  "gae_app"    
 }
 timestamp:  "2017-12-09T13:35:54.764Z"   
}

不确定它是否相关,但projectname.appspot.com/_ah/health会返回此错误:

{
 "code": 5,
 "message": "Method does not exist.",
 "details": [
  {
   "@type": "type.googleapis.com/google.rpc.DebugInfo",
   "stackEntries": [],
   "detail": "service_control"
  }
 ]
}

1 个答案:

答案 0 :(得分:0)

事实证明,端点不能与任务处理程序在同一服务上运行。如果ESP代理在灵活环境中运行相同的服务,并且该服务启用了端点服务,则ESP代理将阻止任务处理程序URL请求。

在单独的服务上运行任务处理程序,不要设置" endpoints_api_service:"在任务处理程序服务app.yaml文件中。

这样做会阻止队列在灵活环境中分派给工作人员。

在app引擎文档中没有提到这有点奇怪。

" / _ ah / health"问题是由于未在open api文件中设置此路径引起的。如果未设置此路径,则代理不会识别该网址。