Analytics - ENOTCONN


Please excuse my ignorance - about Google Analytics, web APIs generally, etc etc etc.

I’m using the Analytics Collection demo project.
I’ve built in both debug and release modes.
I’ve inserted my Google Analytics API key.
My internet connection is stable.

I have found the folder where unsent events would be saved. There is nothing there which suggests to me the connection was made successfully.

But there’s nothing I can see in Google Analytics that looks anything like a button press event log. And whenever an event should be sent I consistently get errors of the type:

AnalyticsCollection[67957:1179079] TIC Read Status [3:0x0]: 1:57

Which I understand is a TCP ENOTCONN (not connected error).

Please help! Any advice on what I should expect would help me feel less crazy. Thank you :slight_smile:


What OS are you running your app on? Do you have the correct permissions to connect to an external server?

Also GA has a considerable lag - you can see live events coming in on some of the screens but you won’t be able to query the collected data for something like 12 hours.


Thanks t0m, I’m on High Sierra 10.13.3. I’m also not sure about external server connection permissions (unsure how to check for that despite a respectable amount of Googling), but I have used web APIs successfully in tutorial apps that I’ve built on this machine before (admittedly on previous OSX versions, but with no special configuration from me).

Not sure if that’s too much info? Thanks!


There shouldn’t be anything stopping outbound network requests on MacOS unless there’s some kind of firewall configured.

One thing you could try is making requests to Google Analytics’ debug endpoint:

The responses from this should give us a bit more info. Can you successfully collect analytics from requests sent by other methods (curl from the command line, for example)?


Thanks again. I’ll try to work through all your suggestions tomorrow.

Meanwhile, I tried validating hits with GA’s Hit Builder (

I looked in the example project’s GoogleAnalyticsDestination class and logged the string passed by

postData.add (appData + eventData.joinIntoString ("&"));

Using my tracking ID, I found this was


When I pasted that into Hit Builder, I noticed that it reformatted the string slightly into


And the hit validated fine.

So I took that reformatted string back into the demo code and pasted it as the argument to postData.add().

The result was that I stopped getting an ENOTCONN on the following connection line

const auto success = webStream->connect (nullptr);

But this only happened when I stepped through the code. Running the code (not debugging), the errors turned up with both formats.

I guess I’ve now sent some valid startup hits, although I still can’t see them in GA. Maybe this is because it takes a while for them to come through, as you said. Or maybe it’s because my GA page is for an iOS product, whereas I should have made it for a (general) measurement protocol product. Will try to suss that too. Cheers!


Curl works, with the hit formatted both ways:

My-MacBook-Pro:~ username$ curl ""
  "hitParsingResult": [ {
    "valid": true,
    "parserMessage": [ ],
    "hit": "/debug/collect?v=1\u0026tid=UA-113596049-1\u0026t=event\u0026ec=info\u0026ea=appStarted\u0026cid=AnonUser1234"
  } ],
  "parserMessage": [ {
    "messageType": "INFO",
    "description": "Found 1 hit in the request."
  } ]
My-MacBook-Pro:~ username$ curl ""
  "hitParsingResult": [ {
    "valid": true,
    "parserMessage": [ ],
    "hit": "/debug/collect?v=1\u0026t=event\u0026tid=UA-113596049-1\u0026cid=AnonUser1234\u0026ec=info\u0026ea=appStarted"
  } ],
  "parserMessage": [ {
    "messageType": "INFO",
    "description": "Found 1 hit in the request."
  } ]


I think that probably addresses all of your suggestions - please let me know if I’ve missed anything :slight_smile:


Well the next thing to try is to use the debug URL in JUCE and parse the response to see if it’s the same.


Right. The debug endpoint is showing valid hits from JUCE.

It looks as if this comes down to (1) me not understanding GA and how complicated it is to set up to show your raw hit data helpfully, (2) the confusion added by the ENOTCONN errors (which still can’t explain) and the mountains of inexplicable information coming into GA (according to which my app has users in California, NY, Florida and Alaska, which is impossible).

Thanks for your help, Tom


Well this forum is public - it’s possible some mischievous folks (or a bot) have taken your API key and have sent you some events…


True but that was well before I posted on here. Mysterious.