We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After the client sets the connection timeout to 2 seconds, if the connection fails, it still takes a long time to return
// 创建WatsonWsClient实例 var client = new WatsonWsClient("192.168.1.11",19405,false); // 设置连接超时为30秒 int timeout = 2; DateTime cc = DateTime.Now; // 创建CancellationTokenSource用于取消连接 var cancellationTokenSource = new CancellationTokenSource(); CancellationToken token = cancellationTokenSource.Token; try { Console.WriteLine("Attempting to connect..."); // 尝试连接到服务器 bool isConnected = client.StartWithTimeout(timeout, token); Console.WriteLine(cc.Subtract(DateTime.Now).TotalSeconds); // 检查连接是否成功 if (isConnected) { Console.WriteLine("Connected to the server successfully."); } else { Console.WriteLine("Failed to connect to the server."); } } catch (Exception ex) { Console.WriteLine("An error occurred: " + ex.Message); } finally { // 停止客户端 //client.Stop(); Console.WriteLine("Client stopped."); }
The text was updated successfully, but these errors were encountered:
Can you reproduce this with the Test.ClientTimeout project? It seems to be working fine for me.
Test.ClientTimeout
Sorry, something went wrong.
WebSocketDemo.zip Out.txt
No branches or pull requests
After the client sets the connection timeout to 2 seconds, if the connection fails, it still takes a long time to return
The text was updated successfully, but these errors were encountered: