I am gettiong this error after send one command: help
Unhandled exception. System.Threading.Tasks.TaskCanceledException: A task was canceled.
at PrimS.Telnet.ByteStreamHandler.IsWaitForIncrementalResponse(DateTime rollingTimeout)
at PrimS.Telnet.ByteStreamHandler.IsResponseAnticipated(Boolean isInitialResponseReceived, DateTime endInitialTimeout, DateTime rollingTimeout)
at PrimS.Telnet.ByteStreamHandler.ReadAsync(TimeSpan timeout)
at JoewAlabelTelnet.Program.RunCommand()
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
The difference is my telnet do not send any character like $ or >
It just appears the blinking underline to write text.
The telnet runs only locally so not need login too.
Here my full code:
private static string data;
private static Client client;
static async Task Main(string[] args)
{
using (client = new Client(args[0], int.Parse(args[1]), new CancellationToken()))
{
data = await client.ReadAsync();
Console.WriteLine(data);
RunCommand();
}
}
static async void RunCommand()
{
await client.WriteAsync(Console.ReadLine());
data = await client.ReadAsync();
Console.WriteLine(data);
RunCommand();
}
I can see the msg after I connect but I got error after try using any command.
Can anyone help me, please?
Thanks!
You didn't await the RunCommand so as soon as that line executes the Main method continues, the CancellationToken falls out of scope and hence you get the error. You'd have neded to await RunCommand();
I am gettiong this error after send one command: help
Unhandled exception. System.Threading.Tasks.TaskCanceledException: A task was canceled. at PrimS.Telnet.ByteStreamHandler.IsWaitForIncrementalResponse(DateTime rollingTimeout) at PrimS.Telnet.ByteStreamHandler.IsResponseAnticipated(Boolean isInitialResponseReceived, DateTime endInitialTimeout, DateTime rollingTimeout) at PrimS.Telnet.ByteStreamHandler.ReadAsync(TimeSpan timeout) at JoewAlabelTelnet.Program.RunCommand() at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
The difference is my telnet do not send any character like $ or > It just appears the blinking underline to write text.
The telnet runs only locally so not need login too. Here my full code:
I can see the msg after I connect but I got error after try using any command. Can anyone help me, please? Thanks!