Handle failure to subscribe gracefully, de-initing soap instead of crashing.
parent
d5d5f33806
commit
20dc0d02fc
|
@ -1016,13 +1016,22 @@ bool Monitor::connect() {
|
||||||
soap->send_timeout = 5;
|
soap->send_timeout = 5;
|
||||||
soap_register_plugin(soap, soap_wsse);
|
soap_register_plugin(soap, soap_wsse);
|
||||||
proxyEvent = PullPointSubscriptionBindingProxy(soap);
|
proxyEvent = PullPointSubscriptionBindingProxy(soap);
|
||||||
|
if (!onvif_url.empty()) {
|
||||||
std::string full_url = onvif_url + "/Events";
|
std::string full_url = onvif_url + "/Events";
|
||||||
proxyEvent.soap_endpoint = full_url.c_str();
|
proxyEvent.soap_endpoint = full_url.c_str();
|
||||||
|
|
||||||
set_credentials(soap);
|
set_credentials(soap);
|
||||||
Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint);
|
Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint);
|
||||||
if (proxyEvent.CreatePullPointSubscription(&request, response) != SOAP_OK) {
|
if (proxyEvent.CreatePullPointSubscription(&request, response) != SOAP_OK) {
|
||||||
Error("Couldn't create subscription! %s, %s", soap_fault_string(soap), soap_fault_detail(soap));
|
const char *detail = soap_fault_detail(soap);
|
||||||
|
Error("Couldn't create subscription! %s, %s", soap_fault_string(soap), detail ? detail : "null");
|
||||||
|
_wsnt__Unsubscribe wsnt__Unsubscribe;
|
||||||
|
_wsnt__UnsubscribeResponse wsnt__UnsubscribeResponse;
|
||||||
|
proxyEvent.Unsubscribe(response.SubscriptionReference.Address, NULL, &wsnt__Unsubscribe, wsnt__UnsubscribeResponse);
|
||||||
|
soap_destroy(soap);
|
||||||
|
soap_end(soap);
|
||||||
|
soap_free(soap);
|
||||||
|
soap = nullptr;
|
||||||
} else {
|
} else {
|
||||||
//Empty the stored messages
|
//Empty the stored messages
|
||||||
set_credentials(soap);
|
set_credentials(soap);
|
||||||
|
@ -1034,10 +1043,13 @@ bool Monitor::connect() {
|
||||||
Event_Poller_Healthy = TRUE;
|
Event_Poller_Healthy = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Warning("You must specify the url to the onvif endpoint");
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
Error("zmc not compiled with GSOAP. ONVIF support not built in!");
|
Error("zmc not compiled with GSOAP. ONVIF support not built in!");
|
||||||
#endif
|
#endif
|
||||||
}
|
} // end if Armcrest of GSOAP
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "Not Starting ONVIF");
|
Debug(1, "Not Starting ONVIF");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue