/// <summary>
        /// Connect to the chat server, and join our channel
        /// </summary>
        /// <param name="userId">Our userId</param>
        /// <param name="channelId">Out channelId</param>
        /// <returns></returns>
        public async Task ConnectAndJoinAsync(uint userId, uint channelId)
        {
            var token = _config["StreamServices:Mixer:Token"];

            _myUserId = userId;
            _channel  = _factory.CreateJsonRpcWebSocket(_logger, _parser);

            // Get chat authkey and endpoints
            var chatData = await _restClient.GetChatAuthKeyAndEndpointsAsync();

            var endpointIndex = Math.Min(1, chatData.Endpoints.Count - 1);             // Skip 1st one, seems to fail often

            // Local function to choose the next endpoint to try
            string getNextEnpoint()
            {
                var endpoint = chatData.Endpoints[endpointIndex];

                endpointIndex = (endpointIndex + 1) % chatData.Endpoints.Count;
                return(chatData.Endpoints[endpointIndex]);
            }

            var continueTrying = true;

            // Local function to join chat channel
            async Task joinAndAuth()
            {
                if (string.IsNullOrEmpty(chatData.Authkey))
                {
                    continueTrying = await _channel.SendAsync("auth", channelId);                      // Authenticating anonymously
                }
                else
                {
                    continueTrying = await _channel.SendAsync("auth", channelId, userId, chatData.Authkey);
                }
            }

            // Local function to join chat channel
            async Task postConnect()
            {
                // Join the channel and send authkey
                await joinAndAuth();

                if (!continueTrying && !string.IsNullOrEmpty(chatData.Authkey))
                {
                    // Try again with a new chatAuthKey
                    chatData = await _restClient.GetChatAuthKeyAndEndpointsAsync();

                    endpointIndex = Math.Min(1, chatData.Endpoints.Count - 1);

                    await joinAndAuth();                     // If this fail give up !
                }
            }

            // Connect to the chat endpoint
            while (continueTrying)
            {
                if (await _channel.TryConnectAsync(getNextEnpoint, null, postConnect))
                {
                    break;
                }
            }

            if (!continueTrying)
            {
                _logger.LogError("Failed to connect to chat endpoint, giving up! (Channel or Token wrong?)");
                _channel.Dispose();
                _channel = null;
                return;
            }
        }