How do I connect the APM agent to the APM server?

I have answered in the StackOverflow thread