When you have CoC loaded, but haven't touched the screen in a while, the message "Anyone there? Press the button below to reload the game" will appear. Fair enough - it prevents people from staying logged into the game forever by disabling the screen lock on their i-device.
Unfortunately, this can also occur if you're in a particularly slow part of a single-player campaign and have deployed a balloon to mop-up the remaining defences; when you reload, you'll be back at your village and the attack will have been terminated.
Note: It can also occur of you're spending a long time on your own village, thinking that you're logged in and safe from attack. As soon as the message appears, you're considered fair-game for the attack matcher and may find that when you do "press the button below" you'll find it won't let you log in 'cos your're being attacked!!
Resolution: jog the screen/change your viewpoint every so-often to ensure that the app thinks you're awake.
Happy SPC-ing