fix: rtmp timeout

This commit is contained in:
langhuihui
2025-09-26 22:32:16 +08:00
parent db045cfa62
commit d8962f4daa
2 changed files with 2 additions and 3 deletions

2
go.mod
View File

@@ -24,6 +24,7 @@ require (
github.com/icholy/digest v1.1.0
github.com/jinzhu/copier v0.4.0
github.com/kerberos-io/onvif v1.0.0
github.com/langhuihui/gotask v0.0.0-20250926063623-e8031a3bf4d2
github.com/mark3labs/mcp-go v0.27.0
github.com/mattn/go-sqlite3 v1.14.24
github.com/mcuadros/go-defaults v1.2.0
@@ -90,7 +91,6 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/juju/errors v1.0.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/langhuihui/gotask v0.0.0-20250926063623-e8031a3bf4d2 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/marcboeker/go-duckdb v1.0.5 // indirect

View File

@@ -77,7 +77,7 @@ func NewNetConnection(conn net.Conn) (ret *NetConnection) {
func (nc *NetConnection) Init(conn net.Conn) {
nc.Conn = conn
nc.BufReader = util.NewBufReader(conn)
nc.BufReader = util.NewBufReaderWithTimeout(conn, 10*time.Second)
nc.bandwidth = RTMP_MAX_CHUNK_SIZE << 3
nc.ReadChunkSize = RTMP_DEFAULT_CHUNK_SIZE
nc.WriteChunkSize = RTMP_DEFAULT_CHUNK_SIZE
@@ -131,7 +131,6 @@ func (nc *NetConnection) ResponseCreateStream(tid uint64, streamID uint32) error
// }
func (nc *NetConnection) readChunk() (msg *Chunk, err error) {
nc.SetReadDeadline(time.Now().Add(time.Second * 5)) // 设置读取超时时间为5秒
head, err := nc.ReadByte()
if err != nil {
return nil, err