If you are getting an RSI, you are either playing with poor technique (your guess), you are tensing up while playing, or both (usually both). If you fix your technique, but still tense up, you can still injure yourself, just slower.
Since I don't play guitar, I'm going to focus on the tensing issue.
When you're challenging yourself, or when you are really into what you are playing, it's very easy to tense your muscles and use much more force than you need to actually play. If you can learn to not do this, it will save yourself a lot of muscle strain.
Every time you finish a piece, take a few seconds to check in with your body. Is your hand or arm tense? If you do get tense, take a minute away from playing to stretch and move. Make it a full minute or two, not a fifteen second pause.
Even if you don't notice getting tense, you should do this three or four times an hour if you are playing for several hours straight. It just gives your body a chance to recover a bit, so that you can last longer.
If you're practicing, rather than playing with friends, the best solution is to slow down until you can play without stress. This might mean going at a boring, glacial pace at first. But if you are practicing with your hand tensed up, you will keep on being tensed up when you're playing with others. But if you practice without tension, the habit will carry over into your regular playing, just like all practicing.
The single best thing I've done to extend my playing time is learning yoga. I started after I started singing, because of all musicians, singers as a group seem to be the most injury-aware, and all the serious singers I know focus heavily on relaxing, stretching, and posture, which are major facets of yoga. If all you want to do it play longer once in a while, it's probably more of a commitment than you need, but it can help.