小编Sum*_*mer的帖子

Node js 中的套接字连接超时错误

我在 Node JS 中将图像上传到 cloudinary 时遇到问题,因为当我尝试这样做时,出现此错误

Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout 
 {
   error: Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout
       at new NodeError (node:internal/errors:399:5)
       at internalConnectMultiple (node:net:1099:20)
       at Timeout.internalConnectMultipleTimeout (node:net:1638:3)
       at listOnTimeout (node:internal/timers:575:11)
       at process.processTimers (node:internal/timers:514:7) {
     code: 'ERR_SOCKET_CONNECTION_TIMEOUT'
   }
 }
Run Code Online (Sandbox Code Playgroud)

有时图像会上传,有时则不会。我在网上查了一下,它说互联网连接很差,但我的互联网足够好,我已经将整个应用程序进行了 Docker 化,所以我不知道这是否与它有关。

const addProduct = async (req: Request, res: Response, next: NextFunction) => {
  const {
    title,
    snippet,
    description,
    quantity,
    price,
    coverImage,
    imageArray,
    category,
  } = req.body;
  try {
    cloudinary.api
      .ping()
      .then((res) => {
        console.log(`Cloudinary connection ${res.status}`);
      })
      .catch((err) => …
Run Code Online (Sandbox Code Playgroud)

javascript rest file-upload node.js typescript

6
推荐指数
2
解决办法
6285
查看次数

标签 统计

file-upload ×1

javascript ×1

node.js ×1

rest ×1

typescript ×1