                 @txconn[senderId].close()
             @txconn[senderId] = senderConn
 
-            @rxconn.send JSON.stringify
-                type: 'senderConnected'
-                senderId: senderId
+            try
+                @rxconn.send JSON.stringify
+                    type: 'senderConnected'
+                    senderId: senderId
+            catch e
+                Log.e e
 
             senderConn.on 'message', (message) =>
                 Log.i "Receive from sender ", message;
-                @rxconn?.send JSON.stringify
-                    type: 'message'
-                    senderId: senderId
-                    data: message
+                try
+                    @rxconn?.send JSON.stringify
+                        type: 'message'
+                        senderId: senderId
+                        data: message
+                catch e
+                    Log.e e
 
             senderConn.on 'close', =>
-                @rxconn?.send JSON.stringify
-                    type: 'senderDisconnected'
-                    senderId: senderId
+                try
+                    @rxconn?.send JSON.stringify
+                        type: 'senderDisconnected'
+                        senderId: senderId
+                catch e
+                    Log.e e
                 @_removeSenderConn senderId
         else
             senderConn.close()

            senderId = messageObj.senderId
            if "*:*" is senderId
                for own _, conn of @txconn
                    conn.send messageObj.data
            else
                txconn = @txconn[senderId]
                if txconn
                    txconn.send messageObj.data
                else
                    @_respReceiverError 'Invalid sender id'


        delete @txconn[senderId]

    _respReceiverError: (message) ->
        try
            @rxconn.send JSON.stringify
                type: 'error'
                message: message
        catch e
            Log.e e

class WebSocketServer

