Encountering Timeout Issues with Reading Streams on Amazon S3 using Express.js

I am currently facing an issue with streaming videos from an Amazon S3 Bucket. It seems that everything works perfectly when calling my REST endpoint once, but the problem arises when trying to stream the video simultaneously from multiple browsers. The error message I receive is: TimeoutError: Connection timed out after 120000ms

Here's a snippet of my code:

var express = require("express");
var fs = require("fs");
var app = express();
var path = require("path");
var AWS = require("aws-sdk");

// Rest of the code...

I'm uncertain whether this issue lies within the aws-sdk-js or if it's a more general problem with streams. Can anyone provide insight into what might be going wrong here? Has anyone else encountered similar difficulties?

Answer №1

After conducting some research, I've discovered that the behavior mentioned above is greatly influenced by the way in which the video is created. I typically use ffmpeg to convert videos to mp4 format. When I include the faststart flag during the conversion process, there is a noticeable decrease in the number of range requests made by the browser when loading the video. With fewer requests being made, both express and aws-sdk are more equipped to handle the situation without any timeouts occurring.

Answer №2

We have the same goal in mind, but our approach is slightly different. Our aim is to control access to the videos through our backend before streaming them to the user. This is why serving videos directly from s3 is not an option for us. It's worth noting that while the video streams smoothly, we are experiencing a timeout of 120000 ms (AWS default) when using getObject() even after the stream has successfully ended. There seems to be an ongoing issue related to this on the aws-sdk repository that has yet to be resolved.

https://github.com/aws/aws-sdk-js/issues/2087

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The specified property cannot be found within the type 'JSX.IntrinsicElements'. TS2339

Out of the blue, my TypeScript is throwing an error every time I attempt to use header tags in my TSX files. The error message reads: Property 'h1' does not exist on type 'JSX.IntrinsicElements'. TS2339 It seems to accept all other ta ...

Unresolved issue with Jade in Angular Routing

Currently, I am working on building a web server using expressjs and jade for the frontend. I have also implemented client-side routing with angularjs but unfortunately, my UI is not displaying as expected. Below you can find my code and the unexpected out ...

Unexpected value detected in D3 for translate function, refusing to accept variable

I'm experiencing a peculiar issue with D3 where it refuses to accept my JSON data when referenced by a variable, but oddly enough, if I print the data to the console and manually paste it back into the same variable, it works perfectly fine. The foll ...

Accessing files after they have been uploaded to a bucket in Google App Engine

After uploading a file using my Google App Engine backend to my storage bucket, I encountered an issue when trying to access the file for use with ffmpeg. The error message received from the try-catch block was: "The input file does not exist". However, up ...

Efficiently process 100 tasks per minute using a microservice architecture

I have a node.js application that needs to perform the following tasks: Retrieve zip files, extract them (containing JS module files with key-value pairs - usually 5-8 files per request) Analyze these files, create new ones from the analysis, and ...

Tips on setting a singular optional parameter value while invoking a function

Here is a sample function definition: function myFunc( id: string, optionalParamOne?: number, optionalParamTwo?: string ) { console.log(optionalParamTwo); } If I want to call this function and only provide the id and optionalParamTwo, without need ...

Transformation of data in Ext JS

Shop: Ext.define('onlineStore.store.market', { model: 'Market', root: 'products', proxy: { type: 'ajax', url: 'http://localhost/onlineStore/data/market.json', reader: { type: ' ...

What sets apart a route handler from a middleware function in ExpressJS?

Could you clarify the distinction between a middleware function and a standard route handler for me? As far as I know, a middleware function is essentially a route handler but with the ability to call the next function parameter to delegate control to an ...

JavaScript - undefined results when trying to map an array of objects

In the process of passing an object from a function containing an array named arrCombined, I encountered a challenge with converting strings into integers. The goal is to map and remove these strings from an object titled results so they can be converted i ...

When using AngularJS and Laravel together, the CORS functionality may cause the POST request to halt after the preflight

Once upon a time, there was a bird who dreamt of joining the postal service but failed his preflight test... Using Laravel as a RESTful API and AngularJS/ionic for the app, everything was working smoothly until suddenly... it stopped. The withCredentials ...

Display the modal in Angular 8 only after receiving the response from submitting the form

I am encountering an issue where a pop-up is being displayed immediately upon clicking the submit button in Angular 8, before receiving a response. I would like the modal to only appear after obtaining the response. Can someone assist me with achieving thi ...

Preventing an image from being repeated when using Canvas drawImage() without having to clear the entire canvas

How can I prevent multiple instances of the same image from smearing across the canvas when drawing it? The platforms seem to stick together and not separate properly. Why do I have to clear the entire rectangle for everything to disappear? Does anyone ha ...

When the audio on the device is in use, the video will not play and vice versa

Whenever my video starts playing, the audio from my device (such as iPod or Spotify) stops. If I try to play the audio manually while the video is playing, the video freezes. Interestingly, when I tested playing an audio file directly within the app, it wo ...

steps for integrating react-pannellum library into react/ionic

Trying to integrate a 3D panorama view into my React Ionic app, but encountering an error while attempting to install using either of the following commands: npm install --save react-pannellum npm install --save pannellum > npm WARN config global `-- ...

What sets apart the method of assigning event handlers using bind() versus each() in jQuery?

Could someone explain the difference between using bind() to assign event handlers and using each() for the same task? $(function () { $('someElement') .bind('mouseover', function (e) { $(this).css({ ...

To link various JavaScript files in WordPress

When working on a project in WP 4.2, I am currently adding JavaScript files like this: add_action('wp_print_scripts', array(&$this, 'admin_load_scripts')); ... function admin_load_scripts() { wp_register_script('BackendAr ...

What could potentially be the reason behind the incapability of the next.js Image component to transform the svg into a

Unique Context I recently developed a minimalist Hero + Navbar using Next.js. The site utilizes the powerful next.js Image component to display images. Surprisingly, all three images on the website, which are in .webp format, load instantly with a size of ...

ReactJS mixes up fetch URLs with another fetch_WRONG_FETCH

I have a fetch function in my Home component: export default function Home() { const { rootUrl } = useContext(UserContext); useEffect(() => { fetch(`${rootUrl}/api/products/featuredProducts`) .then((result) => result.json()) .then ...

Incorporating EJS Template Body Parameters into AWS Lambda's Handler.js Using Serverless.yml

I have a scenario where I am trying to embed an EJS template named 'ui.ejs' into my handler.js file. The goal is to extract URL query parameters, then pass them to a function called 'ui.js' to retrieve data, which will then be displayed ...

Is there a simpler and more refined approach for handling Observables within RxJS pipelines?

Picture this: I have an observable that gives me chocolate cookies, but I only want to eat the ones without white chocolate. Since I am blind, I need to send them to a service to determine if they are white or not. However, I don't receive the answer ...