[Catalyst] Client Disconnect Behavior and Detection

neil at mylunn.id.au neil at mylunn.id.au
Fri Jul 13 04:58:56 GMT 2012

Having a problem with trying to stop further execution of actions in a
controller when the client has disconnected from the server.

I am using XML::Writer in a controller to write directly to the response
object, treating as a file handle. The basic setup is as follows:

  my $writer = XML::Writer->new(
    OUTPUT      => $c->response,
    DATA_INDENT => 2,
    DATA_MODE   => 1,
    CHECK_PRINT => 1

Which all works fine as resulting code outputs to the $writer this is
fed through the response. 

Thing is, as this is generally a lengthy streaming process, if the
client was to disconnect the process continues to run, which is not
desirable. From the XML::Writer documentation, the option has been set
on this instance to CHECK_PRINT, meaning if a write to the file handle
were to fail then an error would be thrown, from which further
processing can be safely shut down.

But the problem here is from the Writer's point of view there is nothing
wrong with the file handle (response) even though the client has

Whose responsibility is this? Engine or Framework? Does anyone know of a
reliable way in which the client hang-up can be detected and where to
look where this should be happening.


More information about the Catalyst mailing list