Your problem could be a bad thermocouple, not enough propane pressure, etc. The first thing I recommend you do before having to take your RV in and have the Water Heater looked at is to do some routine maintenance on it and you might find out that performing this maintenance will solve your problem.
The first thing you should do is watch the video below by RV Expert Mark Polk from RV Education, it gives you the proper steps to maintain your Water Heater. Also pay close attention to the section on adjusting the air mixture on the pilot light because if your pilot light does not have a blue flame this could also be causing your intermittent problem with the water heater. If these steps do not help then you are going to have to take your RV in and have the water heater checked out by a Certified RV Technician.
Everything-About-RVing.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.