diff --git a/rpc/client/http/ws.go b/rpc/client/http/ws.go index f9494bf19..bda943a63 100644 --- a/rpc/client/http/ws.go +++ b/rpc/client/http/ws.go @@ -63,6 +63,12 @@ func newWsEvents(remote string, wso WSOptions) (*wsEvents, error) { return nil, fmt.Errorf("invalid WSOptions: %w", err) } + // remove the trailing / from the remote else the websocket endpoint + // won't parse correctly + if remote[len(remote)-1] == '/' { + remote = remote[:len(remote)-1] + } + w := &wsEvents{ subscriptions: make(map[string]chan ctypes.ResultEvent), } diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index ae99abc61..23603ec0d 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -77,6 +77,14 @@ func TestNilCustomHTTPClient(t *testing.T) { }) } +func TestParseInvalidAddress(t *testing.T) { + _, conf := NodeSuite(t) + // should remove trailing / + invalidRemote := conf.RPC.ListenAddress + "/" + _, err := rpchttp.New(invalidRemote) + require.NoError(t, err) +} + func TestCustomHTTPClient(t *testing.T) { _, conf := NodeSuite(t) remote := conf.RPC.ListenAddress