Synchronization in websocket session to avoid condition races

Change-Id: I9114597bda547ec65e22b0e7995674109228b911
Fix bug in synchronization of websocket

Change-Id: I4a6c2c2dd5bcdc995375e68e93faabfee99adf47