resoved an issue of ts gateway about detection before connect.