Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by hchokshi · Jul 22, 2017 at 07:22 AM · c#dll

Using Azure Application Insights with Unity

Unity 2017.1.0f3

Visual Studio 2015

Using .Net 4.6 experimental scripting for Unity

Update:

With some further investigation, I have found the root issue is that Unity is unable to establish an HTTPS connection with the Azure servers. Would appreciate any advice from people who may have experienced similar HTTPS issues previously.

{System.Security.Cryptography.CryptographicException: Store CA doesn't exists.

at System.Security.Cryptography.X509Certificates.X509Store.Open (System.Security.Cryptography.X509Certificates.OpenFlags flags) [0x0009a] in
{Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a

at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, Mo…}

{Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a

at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x00040] in <59bcb3a41e31492f91d951356644…}

{System.IO.IOException: The authentication or decryption has failed. --->

Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a

at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (Sy…}

{System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host.

Original post:

We're trying to do some advanced analytics for an academic research project which requires a higher level of detail than we can get through unity analytics. For this, we're trying to use Application Insights on Azure.

We set up our unity project to use the .Net Framework 4.6 scripting API and installed the Microsoft.ApplicationInsights nuget package. We have successfully used this nuget package - https://www.nuget.org/packages/Unity.Newtonsoft.Json/ - to get JSON functionality in our project.

However, we are having trouble getting application insights to work correctly. The same code works fine in a C# console application outside of unity. The unity project builds and runs, but the analytics packets are not being sent.

Using fiddler, I had a look at the requests being sent by application insights and noticed a difference between what unity and the console program sent. The C# console application sends a HTTP v1.1 / Keepalive request to setup an HTTPS connection with dc.services.visualstudio.com, then sends a request to /v2/track on that host. The unity application sends a HTTP v1.0 connection (no keep-alive) which gets the below response from the server. No request is sent to /v2/track.

HTTP/1.0 200 Connection Established

FiddlerGateway: Direct

StartTime: 18:30:21.609

Connection: close

alt text

I am unsure why the same library is having different network behaviour inside/outside unity and was wondering if anyone has successfully integrated application insights with unity. We have previously tried unity analytics, but we needed more extensive analytics than available, as well as alternatives like HockeyApp for unity but this does not support custom events on mobile.

untitled.png (6.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by hchokshi · Apr 13, 2018 at 09:59 AM

We created an implementation of ITelemetryChannel that uses a subclass of Transmission that verifies against a bundled copy of the root certificate that the Application Insights SSL certificate is signed with.

     internal class UnityTelemetryTransmission : Transmission
     {
         private const string TelemetryCertResource = "Misc/TelemetryCert";
 
         private static readonly X509Certificate2 RootCertificate;
 
         static UnityTelemetryTransmission()
         {
             var cert = Resources.Load<TextAsset>(TelemetryCertResource);
             RootCertificate = new X509Certificate2(cert.bytes);
             Resources.UnloadAsset(cert);
         }
 
         public UnityTelemetryTransmission(Uri address, byte[] content, string contentType, string contentEncoding,
             TimeSpan timeout = new TimeSpan()) : base(address, content, contentType, contentEncoding, timeout)
         {
         }
 
         protected override WebRequest CreateRequest(Uri address)
         {
             var request = (HttpWebRequest) base.CreateRequest(address);
             request.ServerCertificateValidationCallback = (sender, certificate, chain, errors) =>
             {
                 chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
                 chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
                 chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
                 chain.ChainPolicy.VerificationTime = DateTime.Now;
                 chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 0);
 
                 chain.ChainPolicy.ExtraStore.Add(RootCertificate);
                 return chain.Build((X509Certificate2) certificate);
             };
             return request;
         }
 }

Use the TelemetryConfiguration constructor to specify the ITelemetryChannel you created.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by korzen303 · Apr 12, 2018 at 10:34 AM

Hi @hchokshi,

did you manage to solve this problem?

Cheers

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hchokshi · Apr 13, 2018 at 09:59 AM 0
Share

I've posted our solution below.

avatar image korzen303 · Apr 17, 2018 at 08:59 AM 0
Share

Hi @hchokshi,

big thanks for your reply and code snippet. We have got exactly same problem. However, no network guys in our $$anonymous$$m:(

So on Azure we have simply created an Application Insights resource and copied the Instrumentation $$anonymous$$ey to our code. Worked right away with the console app. Just to add that we want to connect from a standalone Windows desktop apps and not from devices.

I know that it might be trivial question but we are not sure, how to get the TelemetryCertResource certificate? Is this something we need to generate in Azure?

Thanks a lot

avatar image
0

Answer by deadlyfingers · Dec 21, 2018 at 11:35 AM

If you are still looking for solutions I've created an App Insights library for Unity with some scene samples - https://github.com/Unity3dAzure/UnityApplicationInsights/ which you may find helpful.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

397 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cinemachine (or the unity compiler) broken due to some unknown reason 1 Answer

Namespace inside DLL file 0 Answers

(C# - working)(dll - not working) Object reference not set to an instance of an object 1 Answer

can use unity engine in dotnet project 1 Answer

calling Encoding.UTF8.GetBytes(JSON) in a dll causes exception, while in src format everything works great. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges