Warn about EOF errors.

This commit is contained in:
scruzin 2019-01-10 12:48:31 +10:30
parent 076a9c030a
commit e772d37a1b
1 changed files with 4 additions and 1 deletions

View File

@ -35,6 +35,7 @@ LICENSE
package rtmp
import (
"io"
"encoding/binary"
)
@ -101,6 +102,9 @@ func readPacket(s *Session, pkt *packet) error {
err := readN(s, header[:1])
if err != nil {
s.log(DebugLevel, pkg+"failed to read packet header 1st byte", "error", err.Error())
if err == io.EOF {
s.log(WarnLevel, pkg+"EOF error; connection likely terminated")
}
return err
}
pkt.headerType = (header[0] & 0xc0) >> 6
@ -415,7 +419,6 @@ func sendPacket(s *Session, pkt *packet, queue bool) error {
if s.deferred != nil {
// Prepend the previously deferred packet and write it with the current one.
bytes = append(s.deferred, bytes...)
s.deferred = nil
}
err := writeN(s, bytes)
if err != nil {