server: make errors more clear

This commit is contained in:
aler9
2021-10-27 18:55:57 +02:00
parent d43d52fdff
commit 0ff969397d
2 changed files with 15 additions and 15 deletions

View File

@@ -23,12 +23,20 @@ func (e ErrServerSessionNotFound) Error() string {
return "session not found" return "session not found"
} }
// ErrServerSessionTimedOut is an error that can be returned by a server. // ErrServerNoUDPPacketsInAWhile is an error that can be returned by a server.
type ErrServerSessionTimedOut struct{} type ErrServerNoUDPPacketsInAWhile struct{}
// Error implements the error interface. // Error implements the error interface.
func (e ErrServerSessionTimedOut) Error() string { func (e ErrServerNoUDPPacketsInAWhile) Error() string {
return "timed out" return "no UDP packets received in a while"
}
// ErrServerNoRTSPRequestsInAWhile is an error that can be returned by a server.
type ErrServerNoRTSPRequestsInAWhile struct{}
// Error implements the error interface.
func (e ErrServerNoRTSPRequestsInAWhile) Error() string {
return "no RTSP requests received in a while"
} }
// ErrServerTCPFramesEnable is an error that can be returned by a server. // ErrServerTCPFramesEnable is an error that can be returned by a server.
@@ -207,14 +215,6 @@ func (e ErrServerNotAllAnnouncedTracksSetup) Error() string {
return "not all announced tracks have been setup" return "not all announced tracks have been setup"
} }
// ErrServerNoUDPPacketsRecently is an error that can be returned by a server.
type ErrServerNoUDPPacketsRecently struct{}
// Error implements the error interface.
func (e ErrServerNoUDPPacketsRecently) Error() string {
return "no UDP packets received (maybe there's a firewall/NAT in between)"
}
// ErrServerLinkedToOtherSession is an error that can be returned by a server. // ErrServerLinkedToOtherSession is an error that can be returned by a server.
type ErrServerLinkedToOtherSession struct{} type ErrServerLinkedToOtherSession struct{}
@@ -228,7 +228,7 @@ type ErrServerSessionTeardown struct{}
// Error implements the error interface. // Error implements the error interface.
func (e ErrServerSessionTeardown) Error() string { func (e ErrServerSessionTeardown) Error() string {
return "destroyed by a connection" return "teared down by a request"
} }
// ErrServerSessionLinkedToOtherConn is an error that can be returned by a server. // ErrServerSessionLinkedToOtherConn is an error that can be returned by a server.

View File

@@ -315,7 +315,7 @@ func (ss *ServerSession) run() {
now := time.Now() now := time.Now()
lft := atomic.LoadInt64(ss.udpLastFrameTime) lft := atomic.LoadInt64(ss.udpLastFrameTime)
if now.Sub(time.Unix(lft, 0)) >= ss.s.ReadTimeout { if now.Sub(time.Unix(lft, 0)) >= ss.s.ReadTimeout {
return liberrors.ErrServerSessionTimedOut{} return liberrors.ErrServerNoUDPPacketsInAWhile{}
} }
// in case of PLAY and UDP, timeout happens when no RTSP request arrives // in case of PLAY and UDP, timeout happens when no RTSP request arrives
@@ -323,7 +323,7 @@ func (ss *ServerSession) run() {
*ss.setuppedTransport == TransportUDPMulticast): *ss.setuppedTransport == TransportUDPMulticast):
now := time.Now() now := time.Now()
if now.Sub(ss.lastRequestTime) >= ss.s.closeSessionAfterNoRequestsFor { if now.Sub(ss.lastRequestTime) >= ss.s.closeSessionAfterNoRequestsFor {
return liberrors.ErrServerSessionTimedOut{} return liberrors.ErrServerNoRTSPRequestsInAWhile{}
} }
// in case of TCP, there's no timeout until all associated connections are closed // in case of TCP, there's no timeout until all associated connections are closed