diff --git a/protocol/httpflv/server.go b/protocol/httpflv/server.go index 11cc46cc..94e52c5d 100644 --- a/protocol/httpflv/server.go +++ b/protocol/httpflv/server.go @@ -40,7 +40,9 @@ func (server *Server) Serve(l net.Listener) error { mux.HandleFunc("/streams", func(w http.ResponseWriter, r *http.Request) { server.getStream(w, r) }) - http.Serve(l, mux) + if err := http.Serve(l, mux); err != nil { + return err + } return nil } diff --git a/protocol/httpflv/writer.go b/protocol/httpflv/writer.go index 1b582223..92bab49e 100755 --- a/protocol/httpflv/writer.go +++ b/protocol/httpflv/writer.go @@ -42,15 +42,22 @@ func NewFLVWriter(app, title, url string, ctx http.ResponseWriter) *FLVWriter { packetQueue: make(chan *av.Packet, maxQueueNum), } - ret.ctx.Write([]byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0x00, 0x00, 0x00, 0x09}) + if _, err := ret.ctx.Write([]byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0x00, 0x00, 0x00, 0x09}); err != nil { + log.Errorf("Error on response writer") + ret.closed = true + } pio.PutI32BE(ret.buf[:4], 0) - ret.ctx.Write(ret.buf[:4]) + if _, err := ret.ctx.Write(ret.buf[:4]); err != nil { + log.Errorf("Error on response writer") + ret.closed = true + } go func() { err := ret.SendPacket() if err != nil { log.Error("SendPacket error: ", err) ret.closed = true } + }() return ret }