diff --git a/coco/app.py b/coco/app.py
index 6c1b9c81b873eac944baf92a2a55c982d3a090b2..4c44f537845129d61d9af4e4fef99e75d7820179 100644
--- a/coco/app.py
+++ b/coco/app.py
@@ -105,7 +105,10 @@ class Coco:
     def keep_heartbeat(self):
         def func():
             while not self.stop_evt.is_set():
-                self.heartbeat()
+                try:
+                    self.heartbeat()
+                except Exception as e:
+                    logger.error("Unexpected error occur: {}".format(e))
                 time.sleep(config["HEARTBEAT_INTERVAL"])
         thread = threading.Thread(target=func)
         thread.start()
@@ -151,17 +154,20 @@ class Coco:
 
         def func():
             while not self.stop_evt.is_set():
-                sessions_copy = [s for s in Session.sessions.values()]
-                for s in sessions_copy:
-                    # Session 没有正常关闭,
-                    if s.closed_unexpected:
-                        Session.remove_session(s.id)
-                        continue
-                    # Session已正常关闭
-                    if s.closed:
-                        Session.remove_session(s)
-                    else:
-                        check_session_idle_too_long(s)
+                try:
+                    sessions_copy = [s for s in Session.sessions.values()]
+                    for s in sessions_copy:
+                        # Session 没有正常关闭,
+                        if s.closed_unexpected:
+                            Session.remove_session(s.id)
+                            continue
+                        # Session已正常关闭
+                        if s.closed:
+                            Session.remove_session(s)
+                        else:
+                            check_session_idle_too_long(s)
+                except Exception as e:
+                    logger.error("Unexpected error occur: {}".format(e))
                 time.sleep(interval)
         thread = threading.Thread(target=func)
         thread.start()
diff --git a/coco/httpd.py b/coco/httpd.py
index b31ce1ecf57f29fe520fd3319fb7d41e98e1be25..437591adf81c471feaf3018ee0aefb95f827bdf5 100644
--- a/coco/httpd.py
+++ b/coco/httpd.py
@@ -103,7 +103,10 @@ class ProxyNamespace(BaseNamespace):
         forwarder = ProxyServer(client, asset, system_user)
 
         def proxy():
-            forwarder.proxy()
+            try:
+                forwarder.proxy()
+            except Exception as e:
+                logger.error("Unexpected error occur: {}".format(e))
             self.logout(client_id, connection)
         self.socketio.start_background_task(proxy)
 
diff --git a/coco/sshd.py b/coco/sshd.py
index 6d6435dda218747e40829d5fbb2155bc86db37bd..f32f664e98f858be27b3b86f97648a907a04eab3 100644
--- a/coco/sshd.py
+++ b/coco/sshd.py
@@ -110,7 +110,10 @@ class SSHServer:
         kind = client.request.kind
         if kind == 'session' and chan_type in supported:
             logger.info("Request type `{}:{}`, dispatch to interactive mode".format(kind, chan_type))
-            InteractiveServer(client).interact()
+            try:
+                InteractiveServer(client).interact()
+            except Exception as e:
+                logger.error("Unexpected error occur: {}".format(e))
             connection = Connection.get_connection(client.connection_id)
             connection.remove_client(client.id)
         elif chan_type == 'subsystem':