Try cleaning the headphone socket with a cotton bud and some surgical spirit, as well as cleaning the charging socket with a toothbrush. This worked for me.
open