<Session disconnected> error
why do I sometime get a <Session disconnected> error when running a $system.OBJ.Export command from a *.scr script file?
Comments
The most likely reason is that the process is detecting a disconnect of its principal I/O device while OBJ.Export is doing output. When disconnect handling is enabled, InterSystems IRIS reports a disconnect-related error instead of silently ending the process. The relevant setting is DisconnectErr. It controls how the system responds when the principal I/O device is disconnected during an ObjectScript Write or Read. If enabled, the process receives a <DSCON> error; if not enabled, the process exits without reporting an error to the application. This applies to TCP devices and certain terminal devices, including Windows Telnet and Windows local iristerm terminal connections, and only to the principal device. [1]
Important:
This parameter has been retained for compatibility, but should not be used when building new applications. [1]
That helps explain why the same script can behave differently on different servers: the DisconnectErr setting may differ between environments, or the terminal/device context from which the .scr script runs may differ. The setting can be checked and changed in the Management Portal at System Administration > Configuration > Additional Settings > Compatibility, in the DisconnectErr row. It can also be changed in the CPF or via the configuration class. [1]
If you want to change this behavior for just one process rather than the whole instance, the documentation states that there is also a DisconnectErr() method for single-process use. [1]
Sources: