Sounds like you are really having a timeout. You say it sometimes works... Do you have a reception problem with your 3G (or whatever you are using) data network in your area?
If you are surfing the internet from the same location and pages don't load refresh and timeout, then that's probably your problem.
Try where you know the reception is good. You can bypass this problem by catching the exception and retry the sending of the message a few more times before popping a message to the user that the message could not be sent or the such. Better yet would be to save a history of unsent messages so that the user can resend them later. Of course I am assuming that the sending of the message is user driven. If not, you could check the data reception from time to time (every few minutes) and then resend when good enough until it goes through.
Hope that I helped.