Skip to content

Close connection when stopping WsClient. #2258

@ruseinov

Description

@ruseinov

Currently we are using a WsClient in this manner, to monitor tendermint and collect metrics:

func(c *rpcClient.WSClient) error {
		if c.IsRunning() {
			c.Stop() // panics on close c.ResponsesCh when not started (=nil)
		}

But c.Stop() does not close the underlying connection, which results in tendermint logging these errors:

E[08-22|09:35:58.903] Error closing connection                     module=rpc-server protocol=websocket remote=127.0.0.1:52428 err="close tcp 127.0.0.1:46657->127.0.0.1:52428: use of closed network connection"

My proposal would be to add c.conn.Close() to func (c *WSClient) OnStop() {} or Stop() .
I can contribute this myself too.
Let me know what you think.

FYI @ethanfrey

Metadata

Metadata

Assignees

No one assigned

    Labels

    S:waitingStatus: Waiting for responseT:bugType Bug (Confirmed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions