Index: /trunk/FACT++/src/ConnectionSSL.cc
===================================================================
--- /trunk/FACT++/src/ConnectionSSL.cc	(revision 20016)
+++ /trunk/FACT++/src/ConnectionSSL.cc	(revision 20017)
@@ -18,6 +18,4 @@
 namespace dummy = ba::placeholders;
 
-typedef ssl::stream<boost::asio::ip::tcp::socket> stream;
-
 using ba::ip::tcp;
 
@@ -34,5 +32,5 @@
 void ConnectionSSL::AsyncRead(const ba::mutable_buffers_1 buffers, int type)
 {
-    ba::async_read(*this, buffers,
+    ba::async_read(*stream, buffers,
                    boost::bind(&ConnectionSSL::HandleReceivedData, this,
                                dummy::error, dummy::bytes_transferred, type));
@@ -41,5 +39,5 @@
 void ConnectionSSL::AsyncWrite(const ba::const_buffers_1 &buffers)
 {
-    ba::async_write(*this, buffers,
+    ba::async_write(*stream, buffers,
                     boost::bind(&ConnectionSSL::HandleSentData, this,
                                 dummy::error, dummy::bytes_transferred));
@@ -69,5 +67,5 @@
 
     // AsyncConnect + Deadline
-     lowest_layer().async_connect(endpoint,
+    stream->lowest_layer().async_connect(endpoint,
                   boost::bind(&ConnectionSSL::ConnectIter,
                               this, iterator, ba::placeholders::error));
@@ -80,5 +78,5 @@
 {
     // AsyncConnect + Deadline
-     lowest_layer().async_connect(fEndpoint,
+     stream->lowest_layer().async_connect(fEndpoint,
                   boost::bind(&ConnectionSSL::ConnectAddr,
                               this, fEndpoint, ba::placeholders::error));
@@ -87,4 +85,17 @@
     //AsyncWait(fConnectTimeout, 5, &ConnectionSSL::HandleConnectTimeout);
 }
+
+void ConnectionSSL::HandleAsyncShutdown(const bs::error_code &error)
+{
+    stream->lowest_layer().close();
+
+    if (!error || error==error.default_error_condition())
+        return;
+
+    ostringstream str;
+    str << "Shutdown of SSL connection to " << URL() << "[" << error.value() << "]: " << error.message() << " (" << error << ")";// << endl;
+    Error(str);
+}
+
 
 // ------------------------ close --------------------------
@@ -103,5 +114,20 @@
 
     // Close possible open connections
-    lowest_layer().close();
+    if (!IsClosed())
+    {
+        // Adapted from
+        // https://stackoverflow.com/questions/49122521/cant-implement-boostasiosslstreamboostasioiptcpsocket-reconnect
+
+#if BOOST_VERSION < 107000
+        auto& io_context = stream->get_io_service();
+#else
+        const auto& io_context = stream->get_executor();
+#endif
+
+        stream->lowest_layer().cancel(); // Remove all pending stuff in the queue
+        stream->async_shutdown(boost::bind(&ConnectionSSL::HandleAsyncShutdown, this, dummy::error));
+
+        stream.emplace(io_context, *this);
+    }
 
     // Reset the connection status
@@ -128,5 +154,9 @@
 void ConnectionSSL::PostClose(bool restart)
 {
-    get_io_service().post(boost::bind(&ConnectionSSL::CloseImp, this, restart));
+#if BOOST_VERSION < 107000
+    stream->get_io_service().post(boost::bind(&ConnectionSSL::CloseImp, this, restart));
+#else
+    ba::post(boost::bind(&ConnectionSSL::CloseImp, this, restart));
+#endif
 }
 
@@ -265,18 +295,18 @@
     if (!error)
     {
-        lowest_layer().set_option(boost::asio::socket_base::keep_alive(true));
+        stream->lowest_layer().set_option(boost::asio::socket_base::keep_alive(true));
 
         const int optval = 30;
 
-#if BOOST_VERSION <107000
+#if BOOST_VERSION < 107000
         // First keep alive after 30s
-	setsockopt(lowest_layer().native(), SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval));
+	setsockopt(stream->lowest_layer().native(), SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval));
         // New keep alive after 30s
-	setsockopt(lowest_layer().native(), SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval));
+	setsockopt(stream->lowest_layer().native(), SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval));
 #else
         // First keep alive after 30s
-	setsockopt(lowest_layer().native_handle(), SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval));
+	setsockopt(stream->lowest_layer().native_handle(), SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval));
         // New keep alive after 30s
-	setsockopt(lowest_layer().native_handle(), SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval));
+	setsockopt(stream->lowest_layer().native_handle(), SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval));
 #endif
 
@@ -331,5 +361,5 @@
         //set_default_verify_paths();
 
-        async_handshake(stream::client,
+        stream->async_handshake(boost::asio::ssl::stream<boost::asio::ip::tcp::socket>::client,
                         boost::bind(&ConnectionSSL::HandleHandshake, this,
                                     endpoint, dummy::error));
@@ -454,5 +484,9 @@
     else
     {
-        tcp::resolver resolver(get_io_service());
+#if BOOST_VERSION < 107000
+        tcp::resolver resolver(stream->get_io_service());
+#else
+        tcp::resolver resolver(stream->get_executor());
+#endif
 
         tcp::resolver::query query(fAddress, fPort);
@@ -529,6 +563,11 @@
 
 ConnectionSSL::ConnectionSSL(ba::io_service& ioservice, ostream &out) : MessageImp(out),
+#if BOOST_VERSION < 107000
 ssl::context(ioservice, boost::asio::ssl::context::method::sslv23_client),
-stream(ioservice, *this), fLog(0), fVerbose(true), fDebugTx(false),
+#else
+ssl::context(boost::asio::ssl::context::method::sslv23_client),
+#endif
+stream(boost::in_place_init, ioservice, *this),
+fLog(0), fVerbose(true), fDebugTx(false),
 fInTimeout(ioservice), fOutTimeout(ioservice), fConnectionTimer(ioservice),
 fQueueSize(0), fConnectionStatus(kDisconnected)
Index: /trunk/FACT++/src/ConnectionSSL.h
===================================================================
--- /trunk/FACT++/src/ConnectionSSL.h	(revision 20016)
+++ /trunk/FACT++/src/ConnectionSSL.h	(revision 20017)
@@ -8,4 +8,5 @@
 #include <boost/bind.hpp>
 #include <boost/asio.hpp>
+#include <boost/optional.hpp>
 #include <boost/asio/ssl.hpp>
 #include <boost/function.hpp>
@@ -14,7 +15,12 @@
 #include "MessageImp.h"
 
-class ConnectionSSL : public MessageImp, public boost::asio::ssl::context,
-    public boost::asio::ssl::stream<boost::asio::ip::tcp::socket>
+typedef boost::optional<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> Stream;
+
+class ConnectionSSL : public MessageImp, public boost::asio::ssl::context/*,
+    public Stream*/
 {
+public:
+    Stream stream;
+
 private:
     MessageImp *fLog;
@@ -99,4 +105,5 @@
     void HandleSentData(const boost::system::error_code& error, size_t);
     void HandleHandshake(const boost::asio::ip::tcp::endpoint &endpoint, const boost::system::error_code& error);
+    void HandleAsyncShutdown(const boost::system::error_code &error);
 
     int Write(const Time &t, const std::string &txt, int qos=kInfo);
@@ -143,5 +150,5 @@
     bool IsTxQueueEmpty() const { return fQueueSize==0; /*fOutQueue.empty();*/ }
 
-    int IsClosed() const { return !lowest_layer().is_open(); }
+    int IsClosed() const { return !stream->lowest_layer().is_open(); }
 
     bool IsDisconnected() const { return fConnectionStatus==kDisconnected; }
Index: /trunk/FACT++/src/tngweather.cc
===================================================================
--- /trunk/FACT++/src/tngweather.cc	(revision 20016)
+++ /trunk/FACT++/src/tngweather.cc	(revision 20017)
@@ -261,5 +261,5 @@
     void StartReadReport()
     {
-        async_read_some(ba::buffer(fArray),
+        stream->async_read_some(ba::buffer(fArray),
                         boost::bind(&ConnectionWeather::HandleRead, this,
                                     dummy::error, dummy::bytes_transferred));
@@ -466,23 +466,11 @@
         return T::GetCurrentState();
     }
-
-    int Reconnect(const EventImp &evt)
-    {
-        // Close all connections to supress the warning in SetEndpoint
-        fWeather.PostClose(false);
-
-        // Now wait until all connection have been closed and
-        // all pending handlers have been processed
-        poll();
-
-        if (evt.GetBool())
-            fWeather.SetEndpoint(evt.GetString());
-
-        // Now we can reopen the connection
+*/
+    int Connect()
+    {
         fWeather.PostClose(true);
-
         return T::GetCurrentState();
     }
-*/
+
     int Execute()
     {
@@ -515,10 +503,9 @@
             (bind(&StateMachineWeather::Disconnect, this))
             ("disconnect from ethernet");
-
-        AddEvent("RECONNECT", "O")
-            (bind(&StateMachineWeather::Reconnect, this, placeholders::_1))
-            ("(Re)connect ethernet connection to FTM, a new address can be given"
-             "|[host][string]:new ethernet address in the form <host:port>");
 */
+        T::AddEvent("CONNECT", "", State::kDisconnected)
+            (bind(&StateMachineWeather::Connect, this))
+            ("Connect");
+
     }
 
