Closed Z3nto closed 3 years ago
Hi @Z3nto,
The tricky question here is whether PRTG is just doing this randomly (in which case you'd expect to be able to replicate this behavior sometimes when creating sensors in the PRTG UI) or whether there is some new behavior of PRTG that PrtgAPI needs to implement.
The first thing that comes to mind when looking at this error is whether the tmpid
has expired or is no longer valid. In the API request to addsensor2.htm
we establish an add sensor "session" (like you would get when you actually select the sensor to add in the UI). Since these sessions don't actually support the use of GET authentication we utilize a cookie for identifying our previously authenticated session instead. One interesting question could be whether you have a particularly large PRTG install - maybe it takes so long for addsensor5.htm
to execute that the tmpid
has now expired? (that seems unlikely)
I ran a loop of creating ping dynamic sensor parameters and adding them in PowerShell; I let this run 200 times and didn't experience any issues.
The question I would be most interested in is whether this error can actually be ignored - if you kept trying to make the API request, would it eventually succeed? If you can potentially download and compile PrtgAPI (easiest way is probably to open PrtgAPI.sln
, restore NuGet packages then compile)., Then, if you can replace this function
internal void AddObjectInternalDefault(ICommandParameters internalParams, CancellationToken token) =>
RequestEngine.ExecuteRequest(internalParams, token: token);
with something like
internal void AddObjectInternalDefault(ICommandParametersV1 internalParams, CancellationToken token)
{
try
{
while (true)
{
RequestEngine.ExecuteRequest(internalParams, token: token);
return;
}
}
catch(Exception ex)
{
Log("Failed: " + ex.Message + ", retrying", LogLevel.Trace);
Thread.Sleep(10);
}
}
and then compile and run your program with the PrtgClient
's LogLevel
set to Request
and Trace
, hopefully we can somehow replicate the failure, but then also see how it eventually succeeds or maybe changes to a different exception message
In addition, if you look at the Core or Web Server logs on your PRTG Core server, I'd be interested to know whether they provide more information about what exactly the error was (or which object ID it objected to) when you look around the time period this API request was executed
Hi @Z3nto,
Are you able to advise how you went with this/whether you are still experiencing this issue?
Hi @lordmilko sorry for my late response.
I've implemented your loop solution, and since then it worked. Seems that is again some sort of PRTG busy bug. I've not yet found an reason in the log files but I will report it to paessler once i've found one.
Hi @lordmilko ,
I've found a bug that I'm not sure if it is caused by PrtgAPI or by PRTG itself. Maybe you can have a look.
Sporadically my program crashes while creating an ICMP Ping Sensor, it does not occur every time. The error is
Thats my code for creating the ping sensor:
Here is some debugging output:
I'm using PrtgAPI 0.9.14 with PRTG 21.1.65.1767+.
Thanks Z3nto