{"action":"created","issue":{"url":"https://api.github.com/repos/centrifugal/centrifuge-go/issues/17","repository_url":"https://api.github.com/repos/centrifugal/centrifuge-go","labels_url":"https://api.github.com/repos/centrifugal/centrifuge-go/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/centrifugal/centrifuge-go/issues/17/comments","events_url":"https://api.github.com/repos/centrifugal/centrifuge-go/issues/17/events","html_url":"https://github.com/centrifugal/centrifuge-go/pull/17","id":358592194,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MjkwMzQy","number":17,"title":"Mutex in ClientID() method removed","user":{"login":"rocc0","id":16399484,"node_id":"MDQ6VXNlcjE2Mzk5NDg0","avatar_url":"https://avatars1.githubusercontent.com/u/16399484?v=4","gravatar_id":"","url":"https://api.github.com/users/rocc0","html_url":"https://github.com/rocc0","followers_url":"https://api.github.com/users/rocc0/followers","following_url":"https://api.github.com/users/rocc0/following{/other_user}","gists_url":"https://api.github.com/users/rocc0/gists{/gist_id}","starred_url":"https://api.github.com/users/rocc0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rocc0/subscriptions","organizations_url":"https://api.github.com/users/rocc0/orgs","repos_url":"https://api.github.com/users/rocc0/repos","events_url":"https://api.github.com/users/rocc0/events{/privacy}","received_events_url":"https://api.github.com/users/rocc0/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-10T12:03:04Z","updated_at":"2018-09-11T09:32:34Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/centrifugal/centrifuge-go/pulls/17","html_url":"https://github.com/centrifugal/centrifuge-go/pull/17","diff_url":"https://github.com/centrifugal/centrifuge-go/pull/17.diff","patch_url":"https://github.com/centrifugal/centrifuge-go/pull/17.patch"},"body":"When server was shutted down(i.e. docker container stopped) and client starts to reconnect, this mutex stucks client forever. But it works normally when client connects for the first time. Is mutex is a necessery in this metod?\r\nDebugging was made with client from examples(on windows 10 and ubuntu 18.04) and centrifuge server in docker."},"comment":{"url":"https://api.github.com/repos/centrifugal/centrifuge-go/issues/comments/420210209","html_url":"https://github.com/centrifugal/centrifuge-go/pull/17#issuecomment-420210209","issue_url":"https://api.github.com/repos/centrifugal/centrifuge-go/issues/17","id":420210209,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDIxMDIwOQ==","user":{"login":"rocc0","id":16399484,"node_id":"MDQ6VXNlcjE2Mzk5NDg0","avatar_url":"https://avatars1.githubusercontent.com/u/16399484?v=4","gravatar_id":"","url":"https://api.github.com/users/rocc0","html_url":"https://github.com/rocc0","followers_url":"https://api.github.com/users/rocc0/followers","following_url":"https://api.github.com/users/rocc0/following{/other_user}","gists_url":"https://api.github.com/users/rocc0/gists{/gist_id}","starred_url":"https://api.github.com/users/rocc0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rocc0/subscriptions","organizations_url":"https://api.github.com/users/rocc0/orgs","repos_url":"https://api.github.com/users/rocc0/repos","events_url":"https://api.github.com/users/rocc0/events{/privacy}","received_events_url":"https://api.github.com/users/rocc0/received_events","type":"User","site_admin":false},"created_at":"2018-09-11T09:32:34Z","updated_at":"2018-09-11T09:32:34Z","author_association":"NONE","body":"@FZambia yes, every time, only restart of the client helps. Removing the mutex is not a good idea, but idk how to fix it in other way. I've combined code from reconnect and private examples, also added message handler:\r\n```\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"log\"\r\n\t\"time\"\r\n\r\n\t\"github.com/centrifugal/centrifuge-go\"\r\n\t\"github.com/centrifugal/centrifugo/libcentrifugo/auth\"\r\n)\r\n\r\nfunc credentials() *centrifuge.Credentials {\r\n\r\n\ttimestamp := centrifuge.Timestamp()\r\n\r\n\ttoken := auth.GenerateClientToken(\"secret\", \"42\", timestamp, \"\")\r\n\r\n\treturn &centrifuge.Credentials{\r\n\t\tUser:      \"42\",\r\n\t\tTimestamp: timestamp,\r\n\t\tInfo:      \"\",\r\n\t\tToken:     token,\r\n\t}\r\n}\r\n\r\nfunc newConnection(done chan struct{}) centrifuge.Centrifuge {\r\n\tcreds := credentials()\r\n\twsURL := \"ws://localhost:8000/connection/websocket\"\r\n\r\n\tevents := &centrifuge.EventHandler{\r\n\t\tOnPrivateSub: func(c centrifuge.Centrifuge, req *centrifuge.PrivateRequest) (*centrifuge.PrivateSign, error) {\r\n\r\n\t\t\tsign := auth.GenerateChannelSign(\"secret\", req.ClientID, req.Channel, \"\")\r\n\t\t\tprivateSign := &centrifuge.PrivateSign{Sign: sign, Info: \"\"}\r\n\t\t\treturn privateSign, nil\r\n\t\t},\r\n\t\tOnRefresh: func(c centrifuge.Centrifuge) (*centrifuge.Credentials, error) {\r\n\t\t\tlog.Println(\"Refresh\")\r\n\t\t\treturn credentials(), nil\r\n\t\t},\r\n\t\tOnDisconnect: func(c centrifuge.Centrifuge) error {\r\n\t\t\tlog.Println(\"Disconnected\")\r\n\t\t\tstrategy := centrifuge.DefaultBackoffReconnect\r\n\t\t\tstrategy.NumReconnect = 100\r\n\t\t\tstrategy.Max = 20 * time.Second\r\n\t\t\tstrategy.Min = 200 * time.Millisecond\r\n\t\t\terr := c.Reconnect(strategy)\r\n\t\t\tif err != nil {\r\n\t\t\t\tlog.Println(err)\r\n\t\t\t\tclose(done)\r\n\t\t\t} else {\r\n\t\t\t\tlog.Println(\"Reconnected\")\r\n\t\t\t}\r\n\t\t\treturn nil\r\n\t\t},\r\n\t}\r\n\r\n\tc := centrifuge.NewCentrifuge(wsURL, creds, events, centrifuge.DefaultConfig)\r\n\r\n\terr := c.Connect()\r\n\tif err != nil {\r\n\t\tlog.Fatalln(err)\r\n\t}\r\n\treturn c\r\n}\r\n\r\nfunc main() {\r\n\tlog.Println(\"Start program\")\r\n\tdone := make(chan struct{})\r\n\tevents := &centrifuge.SubEventHandler{\r\n\t\tOnMessage: func(sub centrifuge.Sub, msg centrifuge.Message) error {\r\n\t\t\tlog.Println(fmt.Sprintf(\"New message received in channel %s: %#v\", sub.Channel(), msg))\r\n\t\t\treturn nil\r\n\t\t},\r\n\t}\r\n\r\n\tc := newConnection(done)\r\n\tdefer c.Close()\r\n\r\n\t_, err := c.Subscribe(\"$public:chat\", events)\r\n\tif err != nil {\r\n\t\tlog.Fatalln(err)\r\n\t}\r\n\tlog.Println(\"Successfully subscribed on private channel, done\")\r\n\t<-done\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"rocc0"}}