Don't log error when closing connection manually
This commit is contained in:
parent
cb7e12290b
commit
cc0325f7eb
1 changed files with 5 additions and 2 deletions
|
@ -24,6 +24,7 @@ type RPC struct {
|
||||||
client *Client
|
client *Client
|
||||||
http *http.Client
|
http *http.Client
|
||||||
conn io.ReadCloser
|
conn io.ReadCloser
|
||||||
|
stopping bool
|
||||||
rpcSessionId string
|
rpcSessionId string
|
||||||
listenID int
|
listenID int
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ func (r *RPC) ListenReceiveMessages(payload []byte) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (r *RPC) startReadingData(rc io.ReadCloser) {
|
func (r *RPC) startReadingData(rc io.ReadCloser) {
|
||||||
|
r.stopping = false
|
||||||
defer rc.Close()
|
defer rc.Close()
|
||||||
reader := bufio.NewReader(rc)
|
reader := bufio.NewReader(rc)
|
||||||
buf := make([]byte, 2621440)
|
buf := make([]byte, 2621440)
|
||||||
|
@ -122,7 +124,7 @@ func (r *RPC) startReadingData(rc io.ReadCloser) {
|
||||||
n, err = reader.Read(buf)
|
n, err = reader.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var logEvt *zerolog.Event
|
var logEvt *zerolog.Event
|
||||||
if errors.Is(err, io.EOF) && expectEOF {
|
if (errors.Is(err, io.EOF) && expectEOF) || r.stopping {
|
||||||
logEvt = r.client.Logger.Debug()
|
logEvt = r.client.Logger.Debug()
|
||||||
} else {
|
} else {
|
||||||
logEvt = r.client.Logger.Warn()
|
logEvt = r.client.Logger.Warn()
|
||||||
|
@ -174,7 +176,8 @@ func (r *RPC) startReadingData(rc io.ReadCloser) {
|
||||||
|
|
||||||
func (r *RPC) CloseConnection() {
|
func (r *RPC) CloseConnection() {
|
||||||
if r.conn != nil {
|
if r.conn != nil {
|
||||||
r.client.Logger.Debug().Msg("Attempting to connection...")
|
r.client.Logger.Debug().Msg("Closing connection manually")
|
||||||
|
r.stopping = true
|
||||||
r.conn.Close()
|
r.conn.Close()
|
||||||
r.conn = nil
|
r.conn = nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue