I have an Axis IP Camera setup to a Blue Iris server which is acting as a web server. Using the IP Camera Viewer in Ignition, I can connect to that camera’s view via a JPEG Stills mode, however if there is a disconnection whether from the IP Camera to server, or server to Ignition, even if for brief moment, the IP Camera Viewer in Ignition will cut out and give me the error: “Exception: Received HTTP 503: Service Unavailable”.
It will stay this way until the page is refreshed in some way. Is there a setting I’m missing or some way to automatically reconnect?
Wow, this works nice! Too bad there isn’t anything natively built-in, but I simply created a Project Library Script and put the ipcamera.py script in there:
ipcamera.py
from com.inductiveautomation.factorypmi.application.components import PMIIPCamViewer
parserField = PMIIPCamViewer.getDeclaredField("parser")
parserField.setAccessible(True)
for c in PMIIPCamViewer.getDeclaredClasses():
if c.simpleName == 'MJPEGParser':
MJPEGParser = c
break
FrameProducer = MJPEGParser.superclass
stateMethod = FrameProducer.getDeclaredMethod('getState')
stateMethod.setAccessible(True)
badStates = ['ERROR', 'CANCELED']
# Use as a binding expression (on a boolean property) in the IP Camera Viewer like so:
# objectScript("shared.ipcamera.stateCheck(binding.target)", now(1000))
def stateCheck(comp, retv=False):
if comp:
parser = parserField.get(comp)
if parser:
state = stateMethod.invoke(parser)
if str(state) in badStates:
comp.reconnect()
print "Reconnecting %s" % comp
return retv
And then on the Show Stats boolean property on the IP Camera Viewer, I put: