IP Camera Viewer - Exception: Received HTTP 503: Service Unavailable after loss of connection

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?

You might be able to rework the technique for restarting MJPEG streams I describe in my Image Streaming Driver module’s Usage Notes:

https://www.automation-pros.com/streamer/doc/

1 Like

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:

objectScript("ipcamera.stateCheck(binding.target)", now(1000))

I also have your Simulation Aids module, so I was able to use objectScript.