BS-2151, fix exception handling in TCP mode