mirror of
https://github.com/owncast/owncast.git
synced 2025-11-01 19:32:20 +08:00
Add a read timeout when reading rtmp to handle connections that have dropped. Closes #564
This commit is contained in:
@ -114,12 +114,23 @@ func HandleConn(c *rtmp.Conn, nc net.Conn) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we don't get a readable packet in 10 seconds give up and disconnect
|
||||||
|
_rtmpConnection.SetReadDeadline(time.Now().Add(10 * time.Second))
|
||||||
pkt, err := c.ReadPacket()
|
pkt, err := c.ReadPacket()
|
||||||
|
|
||||||
|
// Broadcaster disconnected
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
handleDisconnect(nc)
|
handleDisconnect(nc)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read timeout. Disconnect.
|
||||||
|
if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
|
||||||
|
log.Debugln("Timeout reading the inbound stream from the broadcaster. Assuming that they disconnected and ending the stream.")
|
||||||
|
handleDisconnect(nc)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if err := w.WritePacket(pkt); err != nil {
|
if err := w.WritePacket(pkt); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user