According to Clans of Clans team, it's preferred that a person makes an attack over a stable Wifi network. If you are making attacks while using your phone's network, the connection might be lost in some cases. See also how to make a successful attack.
Connection error messages can happen on slow connections where communication with the server takes more time than it is supposed to take. In this case, the connection isn't actually lost, but the server thinks it was lost.
If your connection is unstable, you are very likely to get disconnected during a battle. Make sure your connection is stable before making an attack. See why Clash of Clans is so addictive.
Even if you have a good connection, a delay in sending certain packets, because of any network congestion, might result in a loss of connection as the packets become out of sync. See what causes lag in online games.
Unlike online games where the game can lag and still work, Clash of Clans cuts the connection if it is about to be slow or laggy.
On online forums, many players suggested that certain IOS versions might be causing this problem. They recommended upgrading the IOS to avoid this problem.
Some people suggest that server side congestion could be responsible for the loss of connection. In such a case, the problem might be with COC servers and not your network. See also how to reduce attacks on your village.
Some players suggest that this could be a bug in the game since they tried many different things and it didn't work for them.