Make sure your connection is wired and not being used too heavily at the time and it seems to improve things a little if you clear your cache beforehand. Hit start, options, network, and then clear the cache.
Other than that, it seems to be a case of timing and connecting when the race you're trying to join is coming to an end. Always take the chance to warm up to see if you've got a good connection as sometimes you can't control the car. It's AI driven. Quit and try again if it does as you haven't got a proper connection and will soon get disconnected.
Keep trying and you'll get in eventually.