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

问题描述

我正在尝试在无服务器的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,"stack": [
            "Error: FetchError: request to https://chat.googleapis.com/v1/spaces/mcqUQQAAAAE/messages?threadKey=spaces%2FmcqUQQAAAAE%2Fthreads%2FhxR5npd4iMI&key=AIzaSyAs5bhTD1JPs8hBsV0PLgQzoezVfRtwm74 Failed,"    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,"    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上搜索,但是没有找到关于此问题的明确答案。 有没有人知道答案,我真的很感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)