Hi viandra,
We're glad you've joined us in Apple Support Communities. Let's see if this helps.
If you're using a USB cable, check to see if Settings > Face ID & Passcode > USB Accessories is enabled. You will need to unlock your iOS device to attach USB accessories if the USB Accessories setting is turned off. Using USB accessories with iOS 11.4.1 and later provides more information about how this feature works.
If you're using Bluetooth, or the issue is different than as mentioned in the above resource for a USB-connected device, follow the steps in If you need help with CarPlay. This link helps you troubleshoot your CarPlay enabled stereo.
If you continue to experience issues, let us know if your iPhone is disconnecting at about an hour and what steps you had a chance to try from the above resources.
We hope that helps with your question and take care!