Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

When streaming a response, calls to write() will hang if the connection has been lost. #76

thaljef opened this Issue Jun 21, 2013 · 0 comments


None yet
1 participant

thaljef commented Jun 21, 2013

Tell me if you can reproduce this. Here's a simple app that streams and infinite response. Notice that a warning is emitted to the server console after each write():

my $app = sub {

    return sub {
        my $responder = shift;
        my $headers = ['Content-Type' => 'text/plain'];
        my $writer  = $responder->( [200, $headers] );

        while (1) {
            $writer->write("SOME OUTPUT\n");
            warn "Wrote stuff\n";

Now launch that on a remote machine, using just one worker (and keep the console open so you can see the warnings).

starman --workers 1 app.psgi

From a different machine, hit the server (e.g):

curl http://remotehost:5000

After you start receiving the stream on localhost, abort the curl command by pressing Ctrl-C.

At this point, the next call to write() appears to block indefinitely, and the server does not emit any more warnings.

But if you do the same experiment using the same machine for both server and client, then write() does not block and the server continues to emit warnings.

I'm using a Mac and a Debian machine as my client & server (respectively). I suspect this has something to do with TCP/IP fundamentals more than it does Starman. So maybe you just need to educate me a bit here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment