无服务器googleapis:建立安全TLS连接之前,客户端网络套接字已断开连接

时间:2020-09-20 11:45:10

标签: node.js lambda serverless-framework google-api-nodejs-client

我正在尝试在无服务器的Lambda中使用googleapis依赖项 它在本地运行良好。但是部署时会出错

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "Error: FetchError: request to https://chat.googleapis.com/v1/spaces/mcqUQQAAAAE/messages?threadKey=spaces%2FmcqUQQAAAAE%2Fthreads%2FhxR5npd4iMI&key=AIzaSyAs5bhTD1JPs8hBsV0PLgQzoezVfRtwm74 failed, reason: Client network socket disconnected before secure TLS connection was established",
    "reason": {
        "errorType": "Error",
        "errorMessage": "FetchError: request to https://chat.googleapis.com/v1/spaces/mcqUQQAAAAE/messages?threadKey=spaces%2FmcqUQQAAAAE%2Fthreads%2FhxR5npd4iMI&key=AIzaSyAs5bhTD1JPs8hBsV0PLgQzoezVfRtwm74 failed, reason: Client network socket disconnected before secure TLS connection was established",
        "stack": [
            "Error: FetchError: request to https://chat.googleapis.com/v1/spaces/mcqUQQAAAAE/messages?threadKey=spaces%2FmcqUQQAAAAE%2Fthreads%2FhxR5npd4iMI&key=AIzaSyAs5bhTD1JPs8hBsV0PLgQzoezVfRtwm74 failed, reason: Client network socket disconnected before secure TLS connection was established",
            "    at Object.reply (/var/task/libs/hangouts.js:102:13)",
            "    at process._tickCallback (internal/process/next_tick.js:68:7)"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: Error: FetchError: request to https://chat.googleapis.com/v1/spaces/mcqUQQAAAAE/messages?threadKey=spaces%2FmcqUQQAAAAE%2Fthreads%2FhxR5npd4iMI&key=AIzaSyAs5bhTD1JPs8hBsV0PLgQzoezVfRtwm74 failed, reason: Client network socket disconnected before secure TLS connection was established",
        "    at process.on (/var/runtime/index.js:37:15)",
        "    at process.emit (events.js:198:13)",
        "    at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)",
        "    at process._tickCallback (internal/process/next_tick.js:69:34)"
    ]
}

一些用法,我的代码:

const { google } = require('googleapis');
const send = async (event) => {
  const api = google.chat({
    version: 'v1',
    auth: process.env.GOOGLE_API_KEY
  });
  return await api.spaces.messages.create({
    parent: event.space.name,
    requestBody: {
      text: 'test'
    }
  })
}

我已经在尝试在Internet上搜索,但是没有找到关于此问题的明确答案。 有没有人知道答案,我真的很感激。

0 个答案:

没有答案
相关问题