diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index ae4d899..db42ab8 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -4,7 +4,6 @@
 #include <sys/socket.h>
 
 #include <boost/container/flat_map.hpp>
-#include <boost/container/flat_set.hpp>
 #include <webserver_common.hpp>
 
 namespace crow
@@ -12,171 +11,176 @@
 namespace obmc_kvm
 {
 
-static std::unique_ptr<boost::asio::ip::tcp::socket> hostSocket;
+static constexpr const uint maxSessions = 4;
 
-// TODO(ed) validate that these buffer sizes are sane
-static boost::beast::flat_static_buffer<1024U * 50U> outputBuffer;
-static boost::beast::flat_static_buffer<1024U> inputBuffer;
-
-static crow::websocket::Connection* session = nullptr;
-
-static bool doingWrite = false;
-
-inline void doWrite();
-
-inline void WriteDone(const boost::system::error_code& ec,
-                      std::size_t bytesWritten)
+class KvmSession
 {
-    BMCWEB_LOG_DEBUG << "Wrote " << bytesWritten << "bytes";
-    doingWrite = false;
-    inputBuffer.consume(bytesWritten);
+  public:
+    explicit KvmSession(crow::websocket::Connection& conn) :
+        conn(conn), doingWrite(false), hostSocket(conn.get_io_context())
+    {
+        boost::asio::ip::tcp::endpoint endpoint(
+            boost::asio::ip::make_address("::1"), 5900);
+        hostSocket.async_connect(
+            endpoint, [this, &conn](const boost::system::error_code& ec) {
+                if (ec)
+                {
+                    BMCWEB_LOG_ERROR
+                        << "conn:" << &conn
+                        << ", Couldn't connect to KVM socket port: " << ec;
+                    if (ec != boost::asio::error::operation_aborted)
+                    {
+                        conn.close("Error in connecting to KVM port");
+                    }
+                    return;
+                }
 
-    if (session == nullptr)
-    {
-        return;
-    }
-    if (ec == boost::asio::error::eof)
-    {
-        session->close("KVM socket port closed");
-        return;
-    }
-    if (ec)
-    {
-        session->close("Error in reading to host port");
-        BMCWEB_LOG_ERROR << "Error in KVM socket write " << ec;
-        return;
+                doRead();
+            });
     }
 
-    doWrite();
-}
-
-inline void doWrite()
-{
-    if (doingWrite)
+    void onMessage(const std::string& data)
     {
-        BMCWEB_LOG_DEBUG << "Already writing.  Bailing out";
-        return;
-    }
-    if (inputBuffer.size() == 0)
-    {
-        BMCWEB_LOG_DEBUG << "inputBuffer empty.  Bailing out";
-        return;
-    }
-
-    doingWrite = true;
-    hostSocket->async_write_some(inputBuffer.data(), WriteDone);
-}
-
-inline void doRead();
-
-inline void readDone(const boost::system::error_code& ec, std::size_t bytesRead)
-{
-    BMCWEB_LOG_DEBUG << "read done.  Read " << bytesRead << " bytes";
-    if (ec)
-    {
-        BMCWEB_LOG_ERROR << "Couldn't read from KVM socket port: " << ec;
-        if (session != nullptr)
+        if (data.length() > inputBuffer.capacity())
         {
-            session->close("Error in connecting to KVM port");
+            BMCWEB_LOG_ERROR << "conn:" << &conn
+                             << ", Buffer overrun when writing "
+                             << data.length() << " bytes";
+            conn.close("Buffer overrun");
+            return;
         }
-        return;
-    }
-    if (session == nullptr)
-    {
-        return;
+
+        BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Read " << data.size()
+                         << " bytes from websocket";
+        boost::asio::buffer_copy(inputBuffer.prepare(data.size()),
+                                 boost::asio::buffer(data));
+        BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Commiting " << data.size()
+                         << " bytes from websocket";
+        inputBuffer.commit(data.size());
+
+        BMCWEB_LOG_DEBUG << "conn:" << &conn << ", inputbuffer size "
+                         << inputBuffer.size();
+        doWrite();
     }
 
-    outputBuffer.commit(bytesRead);
-    std::string_view payload(
-        static_cast<const char*>(outputBuffer.data().data()), bytesRead);
-    BMCWEB_LOG_DEBUG << "Sending payload size " << payload.size();
-    session->sendBinary(payload);
-    outputBuffer.consume(bytesRead);
-
-    doRead();
-}
-
-inline void doRead()
-{
-    std::size_t bytes = outputBuffer.capacity() - outputBuffer.size();
-    BMCWEB_LOG_DEBUG << "Reading " << bytes << " from kvm socket";
-    hostSocket->async_read_some(
-        outputBuffer.prepare(outputBuffer.capacity() - outputBuffer.size()),
-        readDone);
-}
-
-inline void connectHandler(const boost::system::error_code& ec)
-{
-    if (ec)
+  protected:
+    void doRead()
     {
-        BMCWEB_LOG_ERROR << "Couldn't connect to KVM socket port: " << ec;
-        if (session != nullptr)
+        std::size_t bytes = outputBuffer.capacity() - outputBuffer.size();
+        BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Reading " << bytes
+                         << " from kvm socket";
+        hostSocket.async_read_some(
+            outputBuffer.prepare(outputBuffer.capacity() - outputBuffer.size()),
+            [this](const boost::system::error_code& ec, std::size_t bytesRead) {
+                BMCWEB_LOG_DEBUG << "conn:" << &conn << ", read done.  Read "
+                                 << bytesRead << " bytes";
+                if (ec)
+                {
+                    BMCWEB_LOG_ERROR
+                        << "conn:" << &conn
+                        << ", Couldn't read from KVM socket port: " << ec;
+                    if (ec != boost::asio::error::operation_aborted)
+                    {
+                        conn.close("Error in connecting to KVM port");
+                    }
+                    return;
+                }
+
+                outputBuffer.commit(bytesRead);
+                std::string_view payload(
+                    static_cast<const char*>(outputBuffer.data().data()),
+                    bytesRead);
+                BMCWEB_LOG_DEBUG << "conn:" << &conn
+                                 << ", Sending payload size " << payload.size();
+                conn.sendBinary(payload);
+                outputBuffer.consume(bytesRead);
+
+                doRead();
+            });
+    }
+
+    void doWrite()
+    {
+        if (doingWrite)
         {
-            session->close("Error in connecting to KVM port");
+            BMCWEB_LOG_DEBUG << "conn:" << &conn
+                             << ", Already writing.  Bailing out";
+            return;
         }
-        return;
+        if (inputBuffer.size() == 0)
+        {
+            BMCWEB_LOG_DEBUG << "conn:" << &conn
+                             << ", inputBuffer empty.  Bailing out";
+            return;
+        }
+
+        doingWrite = true;
+        hostSocket.async_write_some(
+            inputBuffer.data(), [this](const boost::system::error_code& ec,
+                                       std::size_t bytesWritten) {
+                BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Wrote "
+                                 << bytesWritten << "bytes";
+                doingWrite = false;
+                inputBuffer.consume(bytesWritten);
+
+                if (ec == boost::asio::error::eof)
+                {
+                    conn.close("KVM socket port closed");
+                    return;
+                }
+                if (ec)
+                {
+                    BMCWEB_LOG_ERROR << "conn:" << &conn
+                                     << ", Error in KVM socket write " << ec;
+                    if (ec != boost::asio::error::operation_aborted)
+                    {
+                        conn.close("Error in reading to host port");
+                    }
+                    return;
+                }
+
+                doWrite();
+            });
     }
 
-    doRead();
-}
+    crow::websocket::Connection& conn;
+    boost::asio::ip::tcp::socket hostSocket;
+    boost::beast::flat_static_buffer<1024U * 50U> outputBuffer;
+    boost::beast::flat_static_buffer<1024U> inputBuffer;
+    bool doingWrite;
+};
+
+static boost::container::flat_map<crow::websocket::Connection*,
+                                  std::unique_ptr<KvmSession>>
+    sessions;
 
 inline void requestRoutes(CrowApp& app)
 {
+    sessions.reserve(maxSessions);
+
     BMCWEB_ROUTE(app, "/kvm/0")
         .websocket()
         .onopen([](crow::websocket::Connection& conn) {
             BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
 
-            if (session != nullptr)
+            if (sessions.size() == maxSessions)
             {
-                conn.close("User already connected");
+                conn.close("Max sessions are already connected");
                 return;
             }
 
-            session = &conn;
-            if (hostSocket == nullptr)
-            {
-                boost::asio::ip::tcp::endpoint endpoint(
-                    boost::asio::ip::make_address("127.0.0.1"), 5900);
-
-                hostSocket = std::make_unique<boost::asio::ip::tcp::socket>(
-                    conn.get_io_context());
-                hostSocket->async_connect(endpoint, connectHandler);
-            }
+            sessions[&conn] = std::make_unique<KvmSession>(conn);
         })
-        .onclose(
-            [](crow::websocket::Connection& conn, const std::string& reason) {
-                session = nullptr;
-                hostSocket = nullptr;
-#if BOOST_VERSION >= 107000
-                inputBuffer.clear();
-                outputBuffer.clear();
-#else
-                inputBuffer.reset();
-                outputBuffer.reset();
-#endif
-            })
+        .onclose([](crow::websocket::Connection& conn,
+                    const std::string& reason) { sessions.erase(&conn); })
         .onmessage([](crow::websocket::Connection& conn,
                       const std::string& data, bool is_binary) {
-            if (data.length() > inputBuffer.capacity())
+            if (sessions[&conn])
             {
-                BMCWEB_LOG_ERROR << "Buffer overrun when writing "
-                                 << data.length() << " bytes";
-                conn.close("Buffer overrun");
-                return;
+                sessions[&conn]->onMessage(data);
             }
-
-            BMCWEB_LOG_DEBUG << "Read " << data.size()
-                             << " bytes from websocket";
-            boost::asio::buffer_copy(inputBuffer.prepare(data.size()),
-                                     boost::asio::buffer(data));
-            BMCWEB_LOG_DEBUG << "commiting " << data.size()
-                             << " bytes from websocket";
-            inputBuffer.commit(data.size());
-
-            BMCWEB_LOG_DEBUG << "inputbuffer size " << inputBuffer.size();
-            doWrite();
         });
 }
+
 } // namespace obmc_kvm
 } // namespace crow
