NAME

Plack::App::Proxy::WebSocket - proxy HTTP and WebSocket connections

VERSION

version 0.01

SYNOPSIS

use Plack::App::Proxy::WebSocket;
use Plack::Builder;

builder {
    mount "/socket.io" => Plack::App::Proxy::WebSocket->new(
        remote               => "http://localhost:9000/socket.io",
        preserve_host_header => 1,
    )->to_app;
};

DESCRIPTION

This is a subclass of Plack::App::Proxy that adds support for proxying WebSocket connections. It has no extra dependencies or configuration options beyond what Plack::App::Proxy requires or provides, so it may be an easy drop-in replacement. Read the documentation of that module for advanced usage not covered by the SYNOPSIS.

This subclass necessarily requires extra PSGI server features in order to work. The server must support psgi.streaming and psgix.io. It is also highly recommended to choose a psgi.nonblocking server, though that isn't strictly required; performance may suffer greatly without it. Twiggy is an excellent choice for this application.

This module is EXPERIMENTAL. I use it in development and it works swimmingly for me, but it is completely untested in production scenarios.

CAVEATS

Some servers (e.g. Starman) ignore the Connection HTTP response header and use their own values, but WebSocket clients expect the value of that header to be Upgrade. This module cannot work on such servers. Your best bet is to use a non-blocking server like Twiggy that doesn't mess with the Connection header.

AUTHOR

Charles McGarvey <ccm@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Charles McGarvey.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.