How to avoid ssh :Write failed: Broken pipe?

Hello,

I am trying to run some code on Matlab over ssh . The code takes around 5-6 hours to complete. so after giving the command to run it , I locked my machine and then went off to sleep at night, only to discover in the morning that I get this message :

...Code running, partial results displaying
....
Write failed: Broken pipe

I tried it again, but again I am getting same problem. After 3-4 hours, in the middle, I am again getting "Write failed: Broken pipe" . This was not happening earlier, when I was running ssh to the server in the same city about 10-15 mins walk from the server from my machine. Now I am in a different country than the server, I know that there is straightforward reason as to why this "Write failed: Broken pipe" is continuously happening, But if someone could point out what can be done to prevent it, that would be highly appreciated.

Check out the info on these links:
SSH Write failed: Broken pipe Roger's blog | Roger's blog
[all variants] SSH "Write failed: Broken Pipe" for some users - Ubuntu Forums