diff --git a/include/upnp/upnp_control.h b/include/upnp/upnp_control.h
index 73936165168e95cc03da2448524a31e6d68a99bf..69585392acf34fd82528021921f940def7cedb63 100644
--- a/include/upnp/upnp_control.h
+++ b/include/upnp/upnp_control.h
@@ -31,7 +31,7 @@ namespace upnp {
 
 class UPnPContext;
 
-class Controller
+class Controller : std::enable_shared_from_this<Controller>
 {
 public:
     Controller(const std::shared_ptr<UPnPContext>& ctx);
diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp
index dfe3fecda922b92050c88e05dca09e172d5ed4af..47e730fc3c225ddec5a3a1b6787650aeff384ef3 100644
--- a/src/connectionmanager.cpp
+++ b/src/connectionmanager.cpp
@@ -1473,6 +1473,7 @@ ConnectionManager::Impl::getIceOptions() const noexcept
     IceTransportOptions opts;
     opts.factory = config_->factory;
     opts.upnpEnable = getUPnPActive();
+    opts.upnpContext = config_->upnpCtrl;
 
     if (config_->stunEnabled)
         opts.stunServers.emplace_back(StunServerInfo().setUri(config_->stunServer));
diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp
index a31fdb38827b49c2086bf72abdcdc71b76dfcc59..d187d9ae67e8af2bfc93ce0e84844ef5304db17e 100644
--- a/src/ice_transport.cpp
+++ b/src/ice_transport.cpp
@@ -415,7 +415,7 @@ IceTransport::Impl::initIceInstance(const IceTransportOptions& options)
              initiatorSession_ ? "master" : "slave");
 
     if (upnpEnabled_)
-        upnp_.reset(new upnp::Controller(options.upnpContext));
+        upnp_ = std::make_shared<upnp::Controller>(options.upnpContext);
 
     config_ = options.factory->getIceCfg(); // config copy
     if (isTcp_) {