【问题标题】:Nodejs Elastic benastalk refused to connect to upsteam/ upsteam prematurely closedNodejs Elastic beanstalk拒绝连接上游/上游过早关闭
【发布时间】:2020-10-27 02:26:06
【问题描述】:

在弹性 beanstalk 中运行我的应用程序时出现以下错误:[error] 3636#0: *295 upstream prematurely closed connection while reading response header from upstream [error] 3636#0: *295 connect() failed (111: Connection refused) while connecting to upstream 这很奇怪,因为如果我独立访问这些路由,它可以正常工作。只有从我的 vuex 操作触发这些路由时才会出现错误。

以下是来自 AWS elastic beanstalk 的日志。

以下是访问我的 FFmpeg 路由时的网络选项卡:

以下是从 vuex 触发的生成视频操作。

  async [GENERATE_VIDEO]({state, rootState, dispatch, commit}){
          const username = rootState.user.currentUser.username;
          const s3Id = rootState.templates.currentVideo.stock_s3_id;
          const type = rootState.dataClay.fileFormat || state.type;
          const vid = new Whammy.fromImageArray(state.captures, 30);
             vid.lastModifiedDate = new Date();
             vid.name = "canvasVideo.webm";
          const data = new FormData();
          const id = `${username}_${new Date().getTime()}`;
          data.append("id", id);
          data.append("upload", vid);
          const projectId = await dispatch(INSERT_PROJECT);
          await dispatch(UPLOAD_TEMP_FILE, data);
      const key = await dispatch(CONVERT_FILE_TYPE, { id, username, type, projectId});
      const role = rootState.user.currentUser.role;
      state.file = `/api/files/${key}`;
      let message;
      if(role!='banner'){
        message =`<p>Your video is ready.</p> <a href="${state.file}" download class="btn btn-primary btn-block">Download</a>`;
      } else {
        message = `<p>Your video is ready. You may download your file from your banner account</p>`;
        const resolution = rootState.dataClay.matrix[0];
        await dispatch(EXPORT_TO_BANNER, { s3Id, fileUrl: key, extension: `.${type}`, resolution});
      }

这里是操作中调用的 api 路由。

 async [UPLOAD_TEMP_FILE]({ commit }, data) {
    try {
     const response = await axios.post("/api/canvas-editor/upload-temp", data);
     return response.data;
    } catch (error) {
      console.log(error);
    }
  },
async [CONVERT_FILE_TYPE]({commit}, data) {
    try{
    const response = await axios.post("/api/canvas-editor/ffmpeg", data);
    return response.data;
    } catch(error){
        console.log(error);
    }
  }
  }

正如我所说,我的所有路由都正常工作,并且应用程序在 localhost 上按预期运行,但是当上传到 aws 时,我收到了意外错误。

【问题讨论】:

    标签: node.js amazon-elastic-beanstalk connection-refused


    【解决方案1】:

    经过一番挖掘,我发现我没有设置 ffmpeg 路径。 完成后效果很好。

    const ffmpeg = require('fluent-ffmpeg');
    const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
    ffmpeg.setFfmpegPath(ffmpegPath);
    
    module.exports = ffmpeg;
    

    【讨论】:

      猜你喜欢
      • 2016-11-20
      • 2018-03-12
      • 2017-07-22
      • 2019-05-15
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 2018-09-21
      • 2022-11-27
      相关资源
      最近更新 更多