Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket not always keeping Close promise #27

Open
rbt opened this issue Jan 10, 2020 · 0 comments
Open

Websocket not always keeping Close promise #27

rbt opened this issue Jan 10, 2020 · 0 comments

Comments

@rbt
Copy link

rbt commented Jan 10, 2020

Websocket Close Promise doesn't fire during abnormal closures. A poorly configured firewall lead me to finding out that timed-out connections were not being cleaned up.

The below script simply sets up a socket and tells the user to run ss --kill in another session. This isn't exactly the same as the firewall timeout, but it does demonstrates the same issue.

I do get a "software caused connection abort" message which seems to originate from libuv. A connection timeout doesn't print a message in the terminal.

CRO_TRACE=1 indicates many components receive a DONE event.

use Cro::HTTP::Router;
use Cro::HTTP::Router::WebSocket;
use Cro::HTTP::Server;
use Cro::WebSocket::Client;

my $http-request;
my $application = route {
  get -> 'websocket' {
    $http-request = request;

    web-socket -> $incoming, $close {
      supply {
        whenever $incoming -> $msg {
           await($msg.body).say;
        }
        whenever $close {
           say "NEVER HERE";
        }
      }
    }
  }
}

my $cro-service = Cro::HTTP::Server.new(:http<1.1>, :host<0.0.0.0>, :port<10200>, :$application);
$cro-service.start;

{
    my $connection = await Cro::WebSocket::Client.connect: 'http://localhost:10200/websocket';
    $connection.send('Have Connection');
}

# Text will report "software caused connection abort" but $close will not fire.
say 'Run: sudo ss --kill dst %s/32 dport %s'.sprintf($http-request.connection.peer-host, $http-request.connection.peer-port);

react whenever signal(SIGINT) {
    $cro-service.stop;
    exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant