Insert duplicate entry record on cloud when internet slow why?

My app on cloud sometimes internet is slow when I click insert button first time it wait insert and then I saw it not success and then click insert in section time. I saw it insert duplicate records whent insert but difference _id please suggest me for prevent it.

I have something similar is happening with grounddb and android. I see on server logs inserts failed due to unique index.