diff --git a/src/WebSocketClient.cs b/src/WebSocketClient.cs index e83e47e..6c0eb0d 100644 --- a/src/WebSocketClient.cs +++ b/src/WebSocketClient.cs @@ -289,12 +289,11 @@ private void OnConnectSink(IAsyncResult ar) // Send proxy connection request wsrawstream = wsclient.GetStream(); - string userCreds = proxyUri.UserInfo; string basicAuth = ""; - if (userCreds.Length > 0) + if (proxyUri?.UserInfo != null) { // Base64 encode for basic authentication - userCreds = System.Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(userCreds)); + string userCreds = System.Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(proxyUri.UserInfo)); basicAuth = "\r\nProxy-Authorization: Basic " + userCreds; }