More than likely you have a loose, dirty, or poor ground connection and not necessarly at the plug. Check all ground connections, trailer frame, truck frame, any splices, etc. Plugs get old and worn too. Seen it many times.
Also if you're grounding through the trailer ball without a ground wire that can become a real iffy deal with grease or the accumulation of corrosion under the ball or in the receiver. A ground wire should always be present from the trailer to the vehicle.