Loading plugins/media/media.cpp +33 −11 Original line number Diff line number Diff line Loading @@ -498,11 +498,24 @@ namespace blogi { json_object_object_add(jtable, "rows", jrows); json_object_object_add(jroot, "table", jtable); // Display MediaDB URL (read-only, from node config) // Display configured MediaDB connections (read-only here -- // managed under Settings > Connections, which supports a // failover chain of several URLs, not just one). { std::string urls; size_t n = Args->config->getMediaSourceCount(); for(size_t i = 0; i < n; ++i){ if(i) urls += ", "; urls += Args->config->getMediaSource(i).url; } if(urls.empty()) urls = _mdbUrl; json_object *jinfo = json_object_new_object(); json_object_object_add(jinfo, "label", json_object_new_string(tr(_lang,"MediaDB URL").c_str())); json_object_object_add(jinfo, "value", json_object_new_string(_mdbUrl.c_str())); json_object_object_add(jinfo, "label", json_object_new_string( tr(_lang,"MediaDB URL(s) -- edit under Settings > Connections").c_str())); json_object_object_add(jinfo, "value", json_object_new_string(urls.c_str())); json_object_object_add(jroot, "info", jinfo); } // Combined form: add store json_object *jform = json_object_new_object(); Loading Loading @@ -1022,19 +1035,28 @@ namespace blogi { try { dataResPtr = std::make_unique<libhttppp::HttpResponse>(streamClient->GetStream(dataReq)); } catch(...) { // Pooled connection may be stale — retry with a fresh one. // Assigning a new Handle disposes of the bad connection // (via unique_ptr's own move-assignment) rather than // returning it to the pool for reuse. // Pooled connection may be stale, or its source down // entirely — retry against every configured mediadb // source in turn before giving up. Assigning a new // Handle disposes of the bad connection (via unique_ptr's // own move-assignment) rather than returning it to the // pool for reuse. std::cerr << "media: upstream GetStream failed, retrying with fresh connection" << std::endl; streamClient = CheckoutPool<libhttppp::HttpClient>::Handle( *_mdbStreamPool, std::make_unique<libhttppp::HttpClient>(*_mdbHttpUrl, true, 60, _mdbTrustPolicy)); size_t srcCount = Args->config->getMediaSourceCount(); for(size_t i = 0; i < srcCount && !dataResPtr; ++i){ const auto &src = Args->config->getMediaSource(i); try { libhttppp::HttpUrl freshUrl(src.url); netplus::TlsTrustPolicy freshPolicy; freshPolicy.verifyPeer = src.tlsVerify; streamClient = CheckoutPool<libhttppp::HttpClient>::Handle( *_mdbStreamPool, std::make_unique<libhttppp::HttpClient>(freshUrl, true, 60, freshPolicy)); dataResPtr = std::make_unique<libhttppp::HttpResponse>(streamClient->GetStream(dataReq)); } catch(std::exception &e2) { std::cerr << "media: upstream retry failed: " << e2.what() << std::endl; std::cerr << "media: upstream retry against " << src.url << " failed: " << e2.what() << std::endl; } catch(...) { std::cerr << "media: upstream retry failed: unknown error" << std::endl; std::cerr << "media: upstream retry against " << src.url << " failed: unknown error" << std::endl; } } } Loading Loading
plugins/media/media.cpp +33 −11 Original line number Diff line number Diff line Loading @@ -498,11 +498,24 @@ namespace blogi { json_object_object_add(jtable, "rows", jrows); json_object_object_add(jroot, "table", jtable); // Display MediaDB URL (read-only, from node config) // Display configured MediaDB connections (read-only here -- // managed under Settings > Connections, which supports a // failover chain of several URLs, not just one). { std::string urls; size_t n = Args->config->getMediaSourceCount(); for(size_t i = 0; i < n; ++i){ if(i) urls += ", "; urls += Args->config->getMediaSource(i).url; } if(urls.empty()) urls = _mdbUrl; json_object *jinfo = json_object_new_object(); json_object_object_add(jinfo, "label", json_object_new_string(tr(_lang,"MediaDB URL").c_str())); json_object_object_add(jinfo, "value", json_object_new_string(_mdbUrl.c_str())); json_object_object_add(jinfo, "label", json_object_new_string( tr(_lang,"MediaDB URL(s) -- edit under Settings > Connections").c_str())); json_object_object_add(jinfo, "value", json_object_new_string(urls.c_str())); json_object_object_add(jroot, "info", jinfo); } // Combined form: add store json_object *jform = json_object_new_object(); Loading Loading @@ -1022,19 +1035,28 @@ namespace blogi { try { dataResPtr = std::make_unique<libhttppp::HttpResponse>(streamClient->GetStream(dataReq)); } catch(...) { // Pooled connection may be stale — retry with a fresh one. // Assigning a new Handle disposes of the bad connection // (via unique_ptr's own move-assignment) rather than // returning it to the pool for reuse. // Pooled connection may be stale, or its source down // entirely — retry against every configured mediadb // source in turn before giving up. Assigning a new // Handle disposes of the bad connection (via unique_ptr's // own move-assignment) rather than returning it to the // pool for reuse. std::cerr << "media: upstream GetStream failed, retrying with fresh connection" << std::endl; streamClient = CheckoutPool<libhttppp::HttpClient>::Handle( *_mdbStreamPool, std::make_unique<libhttppp::HttpClient>(*_mdbHttpUrl, true, 60, _mdbTrustPolicy)); size_t srcCount = Args->config->getMediaSourceCount(); for(size_t i = 0; i < srcCount && !dataResPtr; ++i){ const auto &src = Args->config->getMediaSource(i); try { libhttppp::HttpUrl freshUrl(src.url); netplus::TlsTrustPolicy freshPolicy; freshPolicy.verifyPeer = src.tlsVerify; streamClient = CheckoutPool<libhttppp::HttpClient>::Handle( *_mdbStreamPool, std::make_unique<libhttppp::HttpClient>(freshUrl, true, 60, freshPolicy)); dataResPtr = std::make_unique<libhttppp::HttpResponse>(streamClient->GetStream(dataReq)); } catch(std::exception &e2) { std::cerr << "media: upstream retry failed: " << e2.what() << std::endl; std::cerr << "media: upstream retry against " << src.url << " failed: " << e2.what() << std::endl; } catch(...) { std::cerr << "media: upstream retry failed: unknown error" << std::endl; std::cerr << "media: upstream retry against " << src.url << " failed: unknown error" << std::endl; } } } Loading