diff --git a/core/client.go b/core/client.go index adfa03cea..7c2495280 100644 --- a/core/client.go +++ b/core/client.go @@ -23,6 +23,7 @@ type Client struct { zipperAddr string name string // name of the client clientID string // id of the client + reconnCounter uint // counter for reconnection clientType ClientType // type of the client processor func(*frame.DataFrame) // function to invoke when data arrived errorfn func(error) // function to invoke when error occured @@ -166,9 +167,13 @@ func (c *Client) connect(ctx context.Context, addr string) (frame.Conn, error) { return conn, err } + // refresh client id in order to avoid id conflicts on the server-side + clientID := fmt.Sprintf("%s-%d", c.clientID, c.reconnCounter) + c.reconnCounter++ + hf := &frame.HandshakeFrame{ Name: c.name, - ID: c.clientID, + ID: clientID, ClientType: byte(c.clientType), ObserveDataTags: c.opts.observeDataTags, AuthName: c.opts.credential.Name(),