Add Trace and bug correctino

Add trace on socket
Try reconnect
bug fixes