diff --git a/example/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp b/example/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp index 02b6269248..f6af28d2f1 100644 --- a/example/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp +++ b/example/websocket/client/async-ssl-system-executor/websocket_client_async_ssl_system_executor.cpp @@ -114,11 +114,6 @@ class session : public std::enable_shared_from_this if(ec) return fail(ec, "connect"); - // Update the host_ string. This will provide the value of the - // Host HTTP header during the WebSocket handshake. - // See https://tools.ietf.org/html/rfc7230#section-5.4 - host_ += ':' + std::to_string(ep.port()); - // Set a timeout on the operation beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30)); @@ -132,6 +127,11 @@ class session : public std::enable_shared_from_this return fail(ec, "connect"); } + // Update the host_ string. This will provide the value of the + // Host HTTP header during the WebSocket handshake. + // See https://tools.ietf.org/html/rfc7230#section-5.4 + host_ += ':' + std::to_string(ep.port()); + // Perform the SSL handshake ws_.next_layer().async_handshake( ssl::stream_base::client,