I've had particularly annoying (albeit helpful) situations where, even when the enemy has had a spy in my settlement to open the gates, the enemy has not come through the gates. They've had two siege towers, both of which I destroyed, and then they simply lined up outside my walls. They had 4 rams, which they obviously couldn't use - the gates were already open. Extremely annoying.

As to the earlier question, yeah, you should play with the timer for instances like those. If you don't want to wait, then a viable strategy is to place all your missile units on your walls, and lure the enemy in to thin down their ranks bit by bit. Move some units outside, and as soon as the enemy moves and gets close, run back inside your gates. Even if you're all out of ammo, your towers will cause them to take a few casualties. You can do this either until the timer goes off so they take more casualties, or you can do it to destroy a few of their troops to give you the upper hand so you can charge into the open and destroy them.

If you've got any missile cavalry, then you can also harass/retreat.