Stream errors handled
This commit is contained in:
parent
614154b065
commit
7ffcbca830
@ -91,7 +91,8 @@ export class LiveStreaming{
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
await new Promise(async(resolve, reject) => {
|
await new Promise(async(resolve, reject) => {
|
||||||
let stream = await request_stream(this.base_url + segment)
|
let stream = await request_stream(this.base_url + segment).catch((err) => {this.stream.emit('error', err); return null})
|
||||||
|
if(!stream) return
|
||||||
this.request = stream
|
this.request = stream
|
||||||
stream.pipe(this.stream, { end : false })
|
stream.pipe(this.stream, { end : false })
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
@ -180,7 +181,14 @@ export class Stream {
|
|||||||
headers : {
|
headers : {
|
||||||
"range" : `bytes=${this.bytes_count}-${end >= this.content_length ? '' : end}`
|
"range" : `bytes=${this.bytes_count}-${end >= this.content_length ? '' : end}`
|
||||||
}
|
}
|
||||||
})
|
}).catch((err) => {this.stream.emit('error', err); return null})
|
||||||
|
if(!stream) {
|
||||||
|
this.data_ended = true
|
||||||
|
this.bytes_count = 0
|
||||||
|
this.per_sec_bytes = 0
|
||||||
|
this.cleanup()
|
||||||
|
return
|
||||||
|
}
|
||||||
if(Number(stream.statusCode) >= 400){
|
if(Number(stream.statusCode) >= 400){
|
||||||
this.cleanup()
|
this.cleanup()
|
||||||
await this.retry()
|
await this.retry()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user