簡體   English   中英

GCP App Engine whatsapp-web.js 不生成二維碼

[英]GCP App Engine whatsapp-web.js not generating QR code

我有一個使用 whatsapp-web.js 的 node.js 應用程序,我正在使用 Cloud Shell Editor 來執行我的應用程序,當我在 Web 中看到它時 Preview 一切正常,但是當我執行: gcloud app deploy時,我看到了我的 url,未生成二維碼。

我執行了: gcloud app logs tail -s default ,我在控制台中發現了這個錯誤:

/workspace/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:230
error: new Errors_js_1.ProtocolError(),
ProtocolError: Protocol error (Runtime.callFunctionOn): Target closed.

節點版本:18.12.1

這是我的代碼


const express = require("express");
const bodyParser = require("body-parser");
const axios = require("axios");
var cors = require('cors')

const config = require("./config.json");
const { Client, LocalAuth } = require("whatsapp-web.js");

process.title = "whatsapp-node-api";
global.client = new Client({
  authStrategy: new LocalAuth({clientId: "my-client", dataPath: "/tmp"}),
  puppeteer: {
      headless: true,
      ignoreHTTPSErrors: true,
      args: ['--no-sandbox','--disable-setuid-sandbox']
    },
});

global.authed = false;

const app = express();

app.use(cors());

const port = process.env.PORT || config.port;

app.use(bodyParser.json({ limit: "50mb" }));

app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));

client.on("qr", (qr) => {
  console.log("qr");
  process.last_qr = qr;
});

client.on("authenticated", () => {
  console.log("AUTH!");
  authed = true;
  process.last_qr = undefined;
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("disconnected", () => {
  console.log("disconnected");
});
client.initialize();

const chatRoute = require("./components/chatting");
const authRoute = require("./components/auth");

app.use(function (req, res, next) {
  console.log(req.method + " : " + req.path);
  next();
});
app.use("/chat", chatRoute);
app.use("/auth", authRoute);

app.listen(port, () => {
  console.log("Server Running Live on Port : " + port);
});

我的app.yaml

runtime: nodejs18
env: standard
instance_class: F4_1G

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM