rpc/client: handle client creation error in new wsclient
Client returns error if it can't parse endpoint string. WSClient should check client error or there could be panic at `cl.cli = nil` expression.
This commit is contained in:
parent
29e66925aa
commit
aca6f2f3ad
2 changed files with 19 additions and 0 deletions
|
@ -71,6 +71,10 @@ const (
|
|||
// connection). You need to use websocket URL for it like `ws://1.2.3.4/ws`.
|
||||
func NewWS(ctx context.Context, endpoint string, opts Options) (*WSClient, error) {
|
||||
cl, err := New(ctx, endpoint, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cl.cli = nil
|
||||
|
||||
dialer := websocket.Dialer{HandshakeTimeout: opts.DialTimeout}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue