diff --git a/Development/nmos/control_protocol_ws_api.cpp b/Development/nmos/control_protocol_ws_api.cpp index 2fd5e1c67..c6f7d39a8 100644 --- a/Development/nmos/control_protocol_ws_api.cpp +++ b/Development/nmos/control_protocol_ws_api.cpp @@ -225,9 +225,6 @@ namespace nmos const auto& ws_ncp_path = connection_uri.path(); slog::log(gate, SLOG_FLF) << "Received websocket message: " << msg << " on connection: " << ws_ncp_path; - // extract the control protocol api version from the ws_ncp_path - const auto version = nmos::parse_api_version(web::uri::split_path(ws_ncp_path).back()); - auto websocket = websockets.right.find(connection_id); if (websockets.right.end() != websocket) { @@ -241,6 +238,11 @@ namespace nmos { try { + // extract the control protocol api version from the ws_ncp_path + if (web::uri::split_path(ws_ncp_path).empty()) { throw std::invalid_argument("empty URL"); } + const auto version = nmos::parse_api_version(web::uri::split_path(ws_ncp_path).back()); + + // convert message to JSON const auto message = value::parse(utility::conversions::to_string_t(msg)); // validate the base-message