appleboy / gorush

A push notification server written in Go (Golang).
MIT License
7.99k stars 841 forks source link

Running in AWS Lambda push error #443

Open radist opened 4 years ago

radist commented 4 years ago

SETUP: lambda + apigateway ( /{proxy+} - ANY - Method Execution ) Virtual Private Cloud (VPC) - no VPC

By default, Lambda runs your functions in a secure VPC with access to AWS services and the internet. When you connect a function to a VPC in your account, it does not have access to the internet unless your VPC provides access.

CloudWatch Logs for lambda

time="2019/12/03 - 13:11:23" level=debug msg="Init App Status Engine as memory"
time="2019/12/03 - 13:11:23" level=debug msg="worker number is 1, queue number is 8192"
time="2019/12/03 - 13:11:23" level=debug msg="gRPC server is disabled."
time="2019/12/03 - 13:11:23" level=debug msg="HTTPD server is running on 8088 port."
START RequestId: 577298fc-391b-45f8-8b71-0276ae6ef285 Version: $LATEST
time="2019/12/03 - 13:11:23" level=info msg="| header | POST /api/push ***.***.***.** application/x-www-form-urlencoded curl/7.64.0"
[GIN] 2019/12/03 - 13:11:23 | 200 |   19.856858ms |  ***.***.***.** | POST     /api/push
END RequestId: 577298fc-391b-45f8-8b71-0276ae6ef285
REPORT RequestId: 577298fc-391b-45f8-8b71-0276ae6ef285  Duration: 22.44 ms  Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 37 MB  Init Duration: 165.13 ms    
time="2019/12/03 - 13:22:23" level=debug msg="Start push notification for iOS"
time="2019/12/03 - 13:09:16" level=debug msg="Init App Status Engine as memory"
time="2019/12/03 - 13:09:16" level=debug msg="worker number is 1, queue number is 8192"
time="2019/12/03 - 13:09:16" level=debug msg="gRPC server is disabled."
time="2019/12/03 - 13:09:16" level=debug msg="HTTPD server is running on 8088 port."
START RequestId: ec315752-52be-44d3-9449-370e0c82c5bd Version: $LATEST
time="2019/12/03 - 13:09:16" level=info msg="| header | POST /api/push ***.***.***.** application/x-www-form-urlencoded curl/7.64.0"
[GIN] 2019/12/03 - 13:09:16 | 200 |   21.243728ms |  ***.***.***.** | POST     /api/push
END RequestId: ec315752-52be-44d3-9449-370e0c82c5bd
REPORT RequestId: ec315752-52be-44d3-9449-370e0c82c5bd  Duration: 41.48 ms  Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 37 MB  Init Duration: 160.80 ms    
START RequestId: 2d4bef34-c9d1-4df0-a991-f8c490c9f49b Version: $LATEST
time="2019/12/03 - 13:09:16" level=debug msg="Start push notification for Android"
END RequestId: 2d4bef34-c9d1-4df0-a991-f8c490c9f49b
REPORT RequestId: 2d4bef34-c9d1-4df0-a991-f8c490c9f49b  Duration: 1.12 ms   Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 38 MB  
START RequestId: c6e28c9c-0b66-41cb-a187-6942dba42931 Version: $LATEST
time="2019/12/03 - 13:09:23" level=info msg="| header | POST /api/push ***.***.***.** application/x-www-form-urlencoded curl/7.64.0"
[GIN] 2019/12/03 - 13:09:23 | 200 |     136.232µs |  ***.***.***.** | POST     /api/push
time="2019/12/03 - 13:10:49" level=error msg="FCM server send message error: Post https://fcm.googleapis.com/fcm/send: context deadline exceeded"
time="2019/12/03 - 13:10:49" level=debug msg="Start push notification for Android"
time="2019/12/03 - 13:10:49" level=info msg="| header | POST /api/push ***.***.***.** application/x-www-form-urlencoded curl/7.64.0"
[GIN] 2019/12/03 - 13:10:49 | 200 |     137.488µs |  ***.***.***.** | POST     /api/push
END RequestId: c6e28c9c-0b66-41cb-a187-6942dba42931
REPORT RequestId: c6e28c9c-0b66-41cb-a187-6942dba42931  Duration: 1.43 ms   Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 38 MB  

Config file ( GET from https://*************.execute-api.us-west-1.amazonaws.com/prod/api/config)

core:
  enabled: true
  address: ""
  port: "8088"
  max_notification: 100
  worker_num: 2
  queue_num: 8192
  mode: release
  sync: false
  ssl: false
  cert_path: cert.pem
  key_path: key.pem
  cert_base64: ""
  key_base64: ""
  http_proxy: ""
  feedback_hook_url: ""
  pid:
    enabled: false
    path: gorush.pid
    override: true
  auto_tls:
    enabled: false
    folder: .cache
    host: ""
api:
  push_uri: /api/push
  stat_go_uri: /api/stat/go
  stat_app_uri: /api/stat/app
  config_uri: /api/config
  sys_stat_uri: /sys/stats
  metric_uri: /metrics
  health_uri: /healthz
android:
  enabled: true
  apikey: **************************************************************_vGI
  max_retry: 0
ios:
  enabled: false
  key_path: key.pem
  key_base64: ""
  key_type: pem
  password: ""
  production: false
  max_retry: 0
  key_id: ""
  team_id: ""
log:
  format: string
  access_log: stdout
  access_level: debug
  error_log: stderr
  error_level: error
  hide_token: true
stat:
  engine: memory
  redis:
    addr: localhost:6379
    password: ""
    db: 0
  boltdb:
    path: bolt.db
    bucket: gorush
  buntdb:
    path: bunt.db
  leveldb:
    path: level.db
grpc:
  enabled: false
  port: "9000"
slimus commented 4 years ago

@radist did you config your routes ? Like this https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/