Is it continuously happening? If not, then you need to handle this network time-out exception at your end and make the same request again with a few ms delay.
You can place a market exit order when you have reached your desired price(limit is not allowed here). You can check more about the exit_order method here.