Dynatrace / openkit-dotnet

OpenKit .NET Reference Implementation
Apache License 2.0
16 stars 16 forks source link

Session creation fails #120

Open securigy opened 2 years ago

securigy commented 2 years ago

I am using your example and am trying to run it.

  1. However the session creation returns false. So what do I do wrong?
  2. Another issue is that if the IP that I am using for session creation is incorrect (like inactive network adapter then the application hangs forever and I am not able to kill the process neither in Visual Studio (Debug->Stop) not in Task Manager, and in both cases getting "Access is denied" while I am logged in as admin and running the Visual Studio as admin... So how do I resolve at least #1? It is really critical...

` string endpointURL = "https://bf28096kgw.bf.dynatrace.com/mbeacon"; // the endpointURL can be found in the Dynatrace UI ?? What UI? Where? string applicationID = "D2CB8ED1-D63C-4198-B12B-85EFAD1481DB"; // the application id can be found in the Dynatrace UI long deviceID = 42L; // an ID that uniquely identifies the device

        var openKit = new DynatraceOpenKitBuilder(endpointURL, applicationID, deviceID)
            .WithApplicationVersion("1.0")
            .WithOperatingSystem(Environment.OSVersion.VersionString)
            .Build();

        // we wait for OpenKit to be initialized
        // if you skip the line, OpenKit will be initialized asynchronously

        // create a new session
        var ipAddress = GetIpAddress();
        var session = openKit.CreateSession(ipAddress);

        int timeoutInMilliseconds = 30 * 1000;
       // the returned 'success' is false
        bool success = openKit.WaitForInitCompletion(timeoutInMilliseconds);`
TheHighriser commented 2 years ago

Hi,

So you said in the example "the endpointURL can be found in the Dynatrace UI ?? What UI? Where?" - So do you actually have access to a Dynatrace Server? Within the web UI of the server you can create an custom application, which provides you a wizard that is containing all this kind of information.

So did you use this data? Because if not this would explain the session creation returning false.

stefaneberl commented 2 years ago

Hi,

ad issue 1: Please be aware that not the session creation returns false, but rather your wait call to wait for OpenKit to be initialized. This is a typical indicator that either your endpoint URL or your application ID is invalid. If those values are correct, then there might be an issue reaching the endpoint URL. The values can be found in the application's settings UI, to be exact in the instrumentation wizard.

ad issue 2: Unfortunately I do not see how you determine your IP, so I cannot give you any advice. However, there is an overloaded parameterless CreateSession method, where the IP is determined "automatically" on the receiving end. See also https://github.com/Dynatrace/openkit-dotnet/blob/main/src/Dynatrace.OpenKit/API/IOpenKit.cs#L86

Another hint, please do not specify a hardcoded deviceID, as this value should be unique per device/installation, depending on your use case.

Best regards Stefan

securigy commented 2 years ago

I found the reason for not being able to reach the endpoint with valid URL and app ID. The wait for initialization was infinite and I was unable to stop debugging or kill the process due to presence of Norton 360 that was also controlling Windows Firewall. Although identifying Norton 360 fault is a positive/resolving thing, the fact remains the same - inability to stop debugging or killing the process is totally due to your threading issue - probably starting another non-background thread... That concludes my advisement. Leon On Sunday, January 9, 2022, 11:20:17 PM PST, Stefan Eberl @.***> wrote:

Hi,

ad issue 1: Please be aware that not the session creation returns false, but rather your wait call to wait for OpenKit to be initialized. This is a typical indicator that either your endpoint URL or your application ID is invalid. If those values are correct, then there might be an issue reaching the endpoint URL. The values can be found in the application's settings UI, to be exact in the instrumentation wizard.

ad issue 2: Unfortunately I do not see how you determine your IP, so I cannot give you any advice. However, there is an overloaded parameterless CreateSession method, where the IP is determined "automatically" on the receiving end. See also https://github.com/Dynatrace/openkit-dotnet/blob/main/src/Dynatrace.OpenKit/API/IOpenKit.cs#L86

Another hint, please do not specify a hardcoded deviceID, as this value should be unique per device/installation, depending on your use case.

Best regards Stefan

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

stefaneberl commented 2 years ago

Happy to hear you found the cause of your problem.

I've created a test application and specified a non-existing application id, to block the WaitForInitCompletion call. I'm able to stop debugging in Visual Studio (2019) while waiting for the call and I'm also able to kill the process in Task Manager. So I would assume it's not our code that is causing your stop/kill issue.

securigy commented 2 years ago

As I mentioned - try to install Norton 360 and watch the issue I described. On Monday, January 10, 2022, 11:19:43 PM PST, Stefan Eberl @.***> wrote:

Happy to hear you found the cause of your problem.

I've created a test application and specified a non-existing application id, to block the WaitForInitCompletion call. I'm able to stop debugging in Visual Studio (2019) while waiting for the call and I'm also able to kill the process in Task Manager. So I would assume it's not our code that is causing your stop/kill issue.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

stefaneberl commented 2 years ago

I'm awfully sorry, but I will not install Norton 360 on my machine, for several reasons. If Norton 360 is interfering with Visual Studio and/or Task Manager, I recommend contacting the Norton Support (https://support.norton.com/sp/en/us/home/current/contact).

securigy commented 2 years ago

Let me clarify again. I work for a client. The code for this client did not work hanging and waiting for initialization. I was suspecting App ID and endpoint URL since I also tried your examples that exhibited the same behavior: the app hangs without ability to stop debugging inVS2019 and not being able to kill the process in Task Manager (access denied).  I tried everything I could at no avail. At the same time the same code worked on client's machines.So, I researched firewall and found that it was controlled by Norton 360 that was running on my dev machine. I removed Norton 360 and everything started working, so it wasn't App ID or URL, but Norton  360. I reported this thinking that this information might be useful to you - IMO, despite that its Norton 360/firewall fault any app (including yours) should not behave like that. That's all. If it is not not useful to you then ignore it, but don't send me to Norton - I resolved it be removing Norton 360 but not every customer of yours will do the same... Leon On Wednesday, December 29, 2021, 02:40:18 AM PST, Matthias Hochrieser @.***> wrote:

Hi,

So you said in the example "the endpointURL can be found in the Dynatrace UI ?? What UI? Where?" - So do you actually have access to a Dynatrace Server? Within the web UI of the server you can create an custom application, which provides you a wizard that is containing all this kind of information.

So did you use this data? Because if not this would explain the session creation returning false.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

stefaneberl commented 2 years ago

Hi @securigy,

sorry if my comment sounded offensive to you. That was not my intention. I appreciate your findings and that you're sharing them with us. We'll keep them in mind, for future troubleshooting.

Best regards Stefan