Reolink long poll recover (#97465)
This commit is contained in:
parent
1f11ce63fc
commit
c32b15c754
1 changed files with 20 additions and 2 deletions
|
@ -267,7 +267,19 @@ class ReolinkHost:
|
||||||
async def _async_start_long_polling(self):
|
async def _async_start_long_polling(self):
|
||||||
"""Start ONVIF long polling task."""
|
"""Start ONVIF long polling task."""
|
||||||
if self._long_poll_task is None:
|
if self._long_poll_task is None:
|
||||||
await self._api.subscribe(sub_type=SubType.long_poll)
|
try:
|
||||||
|
await self._api.subscribe(sub_type=SubType.long_poll)
|
||||||
|
except ReolinkError as err:
|
||||||
|
# make sure the long_poll_task is always created to try again later
|
||||||
|
if not self._lost_subscription:
|
||||||
|
self._lost_subscription = True
|
||||||
|
_LOGGER.error(
|
||||||
|
"Reolink %s event long polling subscription lost: %s",
|
||||||
|
self._api.nvr_name,
|
||||||
|
str(err),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self._lost_subscription = False
|
||||||
self._long_poll_task = asyncio.create_task(self._async_long_polling())
|
self._long_poll_task = asyncio.create_task(self._async_long_polling())
|
||||||
|
|
||||||
async def _async_stop_long_polling(self):
|
async def _async_stop_long_polling(self):
|
||||||
|
@ -319,7 +331,13 @@ class ReolinkHost:
|
||||||
try:
|
try:
|
||||||
await self._renew(SubType.push)
|
await self._renew(SubType.push)
|
||||||
if self._long_poll_task is not None:
|
if self._long_poll_task is not None:
|
||||||
await self._renew(SubType.long_poll)
|
if not self._api.subscribed(SubType.long_poll):
|
||||||
|
_LOGGER.debug("restarting long polling task")
|
||||||
|
# To prevent 5 minute request timeout
|
||||||
|
await self._async_stop_long_polling()
|
||||||
|
await self._async_start_long_polling()
|
||||||
|
else:
|
||||||
|
await self._renew(SubType.long_poll)
|
||||||
except SubscriptionError as err:
|
except SubscriptionError as err:
|
||||||
if not self._lost_subscription:
|
if not self._lost_subscription:
|
||||||
self._lost_subscription = True
|
self._lost_subscription = True
|
||||||
|
|
Loading…
Add table
Reference in a new issue