danikf / tik4net

Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.
Apache License 2.0
174 stars 93 forks source link

Reboot/Shutdown causes IOException #100

Open Deantwo opened 6 months ago

Deantwo commented 6 months ago

Using the /system/reboot or /system/shutdown command will cause an IOException. Not sure what would be a good solution to this issue.

>/system/reboot
<
<
Exception thrown: 'System.IO.IOException' in tik4net.dll
>/quit
<
<
System.IO.IOException: Can not read sentence from connection
   at tik4net.Api.ApiConnection.ReadSentence()
   at tik4net.Api.ApiConnection.GetOne(String tag)
   at tik4net.Api.ApiConnection.<GetAll>d__54.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at tik4net.Api.ApiConnection.CallCommandSync(String[] commandRows)
   at tik4net.Api.ApiCommand.ExecuteNonQuery()
   at ...

Example code:

TikConnection con = ConnectionFactory.OpenConnection(Type.Api, _host, _username, _password);
ITikCommand cmd = conn.CreateCommand("/system/reboot");
System.Diagnostics.Debug.WriteLine("Executing reboot");
cmd.ExecuteNonQuery();
System.Diagnostics.Debug.WriteLine("Reboot executed");