I tried everything mentioned here, some things appeared at first to work but didn’t, much the same as the experience of others. That includes the hardware fix of replacing the sim card tray, which I did twice just to be sure the first replacement part wasn’t itself defective.
But now it is fixed. Truly. The solution was to replace the motherboard. Which was surprisingly easy and cheap, Samsung did it for me for $70, total cost, even though my phone was almost two years old and out of warranty and I had no other kind of protection plan.
Here’s their policy. You call them, tell your story. They email you a second day air UPS label, no charge, to use to send your phone to their repair place near Dallas. If they can fix your phone by software revisions, they do so and send it back, no charge. If they conclude they need to change a part (my case), they call you for a credit card number, charge you $70 no matter what the part is, fix it and send it back. In my case they called two days after they got it, fixed it and sent it back to me (again, by second day air) the next day. Only exceptions: if they have to replace the display (not relevant in my case), it’s $100, not $70. And if they discover it’s corroded when they open it because you got the phone wet, they don’t fix it. Not my case.
One warning: I carefully explained that I had already tried replacing the sim card tray twice and it was clearly something else, and also that the problem was intermittent so that tray replacements seemed at first to work, but the problem soon came back. Despite that, they initially replaced the tray and sent it back. And of course, after a few days the problem reappeared. But when I called them, they were quite pleasant, connected me to a second level help person, who wrote up a “special order” directing they the repair people to replace the motherboard, and directing that the phone be handled on an expedited basis. Sent me new label, and it all worked as he said. Of course, no further charge.
Anyway, I’ve been using the phone now about ten days, it works better than ever. Oddly, the battery life (with the original, old battery) even seems to have gotten better. But the main thing, the sim card tray problem is fixed.