Skip to content

Commit

Permalink
fix: server doesn't dispatch message after sfn reconnected (#710)
Browse files Browse the repository at this point in the history
guarantee clientID will be changed after reconnect.
  • Loading branch information
wujunzhuo authored Jan 25, 2024
1 parent 5f97bc8 commit 304ae81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down

1 comment on commit 304ae81

@vercel
Copy link

@vercel vercel bot commented on 304ae81 Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yomo – ./

yomo-git-master-yomorun.vercel.app
yomo-yomorun.vercel.app
yomo.vercel.app
yomo.run
www.yomo.run

Please sign in to comment.