Two things that might help-
Clean the lightning connectors with alcohol. Sometimes gunk can build up on them and prevent a solid contact from being made.
Get some electronic cleaning gel for the ports themselves. This stuff is pretty amazing.