koajs / discussions

KoaJS Discussions
2 stars 2 forks source link

EPIPE error occurs when the server returns mp3 file. #13

Open Ch0ikyle opened 4 years ago

Ch0ikyle commented 4 years ago

I want to play music that received from my server. it works properly without error when I test it in the local, but EPIPE errors occur when I test it in the server.

const mp3 = fs.createReadStream(`../music-uploader/${low_mp3}`);
ctx.response.set("content-type", "audio/mp3");
ctx.response.set("Accept-Ranges", 'bytes');
ctx.body = mp3;

It is my code and I don't know how to fix it.

  Error: write EPIPE
  at _errnoException (util.js:1022:11)
  at WriteWrap.afterWrite (net.js:867:14)

why it happens???

Ch0ikyle commented 4 years ago

I solved this error by changing code:

const mp3 = fs.readFileSync();

but, fundamental problem remains.

Actually, My app stops when app calls that API. I thought this was due to EPIPE error. However, the app still stops...