#!/usr/bin/env perl use warnings; use strict; use Mojolicious::Lite; get '/' => 'index'; websocket '/echo' => sub { my $c = shift; $c->app->log->debug('WebSocket opened'); $c->inactivity_timeout(300); my $msg1 = `date`; $c->send($msg1); $c->on(finish => sub { my ($c, $code, $reason) = @_; $c->app->log->debug("WebSocket closed with status $code"); }); }; app->start; __DATA__ @@ index.html.ep Test