I think your problem is at the truck side connection. The plug probably has loose or dirty connections.
I would start there by taking the plug apart and inspecting/cleaning and tightening the connections.
I am going to move this thread to the towing section for more assistance.
Scott-2013 F350 with a lot of tires.
2013 40' 4-slider stoneridge 5th wheel coming in at 15,400; 2015 Lincoln MKC
Previous Truck 2008 F250 6.4 with lots of upgrades and a suspension upgrade from Torklift International StableLoads