GithubHelp home page GithubHelp logo

sockjs-perl's Introduction

Build Status MetaCPAN Release Kritika Status Kritika Status Kritika Status

NAME

SockJS - SockJS Perl implementation

SYNOPSIS

use Plack::Builder;
use SockJS;

builder {
    mount '/echo' => SockJS->new(
        handler => sub {
            my ($session) = @_;

            $session->on(
                'data' => sub {
                    my $session = shift;

                    $session->write(@_);
                }
            );
        };
    );
};

DESCRIPTION

SockJS is a Perl implementation of http://sockjs.org.

WARNINGS

When using Twiggy there is no chunked support, thus try my fork http://github.com/vti/Twiggy.

EXAMPLE

See example/ directory.

DEVELOPMENT

Repository

http://github.com/vti/sockjs-perl

CREDITS

Matthew Lien (github/BlueT)

Mohammad S Anwar (github/manwar)

AUTHOR

Viacheslav Tykhanovskyi, [email protected].

COPYRIGHT AND LICENSE

Copyright (C) 2013-2018, Viacheslav Tykhanovskyi

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

sockjs-perl's People

Contributors

bluet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sockjs-perl's Issues

"Can't call method ... "

I get the following error, when Chrome Browser is connected using SockJS by wecksocket connection, and i hit reload in the browser:

Can't call method "push_write" on an undefined value at /usr/local/share/perl/5.14.2/SockJS/Transport/WebSocket.pm line 106
... and the perl script aborts.

Can't locate object method "read" via package "IO::File"

With 0.05 and perl 5.12.x the test suite fails:

#   Failed test 'No tests run for subtest "return error when content length not equals actual read data"'
#   at t/transport/jsonp-send.t line 40.
Can't locate object method "read" via package "IO::File" at /tmpfs/.cpan-build-cpansand/2018082618/SockJS-0.05-2/blib/lib/SockJS/Transport/JSONPSend.pm line 51.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 2.
t/transport/jsonp-send.t ..... 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/2 subtests 
...
#   Failed test 'No tests run for subtest "return error when content length not equals actual read data"'
#   at t/transport/xhr-send.t line 40.
Can't locate object method "read" via package "IO::File" at /tmpfs/.cpan-build-cpansand/2018082618/SockJS-0.05-2/blib/lib/SockJS/Transport/XHRSend.pm line 46.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 2.
t/transport/xhr-send.t ....... 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/2 subtests 

I vaguely remember that this can be fixed with a "use IO::File", but I can be wrong.

With older perls (5.10.x, 5.8.x) the error message is different:

Can't locate object method "read" via package "IO::Handle" at /home/cpansand/.cpan/build/2018082618/SockJS-0.05-0/blib/lib/SockJS/Transport/JSONPSend.pm line 51.

"any" is not exported by the List::Util module

On a CentOS7 system with the system perl the test suite fails:

...
"any" is not exported by the List::Util module
Can't continue after import errors at /home/cpansand/.cpan/build/2018120210/SockJS-0.08-DX7S4T/blib/lib/SockJS/Transport/Base.pm line 6.
BEGIN failed--compilation aborted at /home/cpansand/.cpan/build/2018120210/SockJS-0.08-DX7S4T/blib/lib/SockJS/Transport/Base.pm line 6.
Compilation failed in require at t/transport/base.t line 6.
BEGIN failed--compilation aborted at t/transport/base.t line 6.
t/transport/base.t ........... 
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run 
... (etc) ...

On this system List::Util 1.27 is installed.

The example provided with this module failed

In the top-level README.md of this module, you get "The Client-Side Part" and "The Server-Side Part". I tried those out with Twiggy, using both version 0.3.4 and version 0.2.1 of the client, and when I try to load my webpage I get the following error on FireBug (latest FF):

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data
[Break On This Error]   
var info = JSON.parse(text); sockjs-0.2.1.js (line 1649)

So I look at the client code and insert a debugging line: console.log(text) right before JSON-parsing it, and see that text is not JSON at all! See for yourself below:

4f
{"origins":["*:*"],"entropy":3020163857,"websocket":true,"cookie_needed":false}
0

The "4f' and the "0" on the top & bottom are creating the problem.

Whose fault is it, vti? What can we do to fix it? I'm anxious to become a SockJS-Perl user!

Thanks

Responses always returned chunked

Without supplying a Content-Length, responses were automatically chunked by Middleware::Chunked. I produced the following with the supplied test client, testing on Firefox and Chromium -- removing the chunked middleware or adding a Content-Length to a response resolved the issue in the response and browser.

GET /echo/info HTTP/1.1

HTTP/1.0 200 OK
Content-Type: application/json; charset=UTF-8
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Access-Control-Allow-Headers: origin, content-type
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Transfer-Encoding: chunked

4f
{"origins":["*:*"],"entropy":3562916858,"websocket":true,"cookie_needed":false}
0

Client example

Hi,

I'm missing an example that shows how to use the SockJS implementation as a client to send Json RPC2 information via the connection.

KR,

G.

SockJS is not on CPAN

SockJS is not on CPAN.

If it were on CPAN, I would be able to install it more easily, and be able to update it together with the rest of my perl modules.

Now it is hard to make sure it is up-to-date.

Minimum perl version

Probably the distribution should declare 5.010 as minimum perl version --- or alternatively get rid of defined-or usage. I see with perl 5.8.1 the following error in the test suite:

Search pattern not terminated at /tmpfs/.cpan-build-cpansand/2018082615/SockJS-0.04-jQK0kG/blib/lib/SockJS/Middleware/Cors.pm line 22.
Compilation failed in require at t/middleware/cors.t line 6.
BEGIN failed--compilation aborted at t/middleware/cors.t line 6.
t/middleware/cors.t .......... 
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run 

t/transport/jsonp-send.t and t/transport/xhr-send.t started to fail

My smokers started to report test failures:

...
    #   Failed test at t/transport/jsonp-send.t line 85.
    #     Structures begin differing at:
    #          $got->[0] = '200'
    #     $expected->[0] = '500'
    # Looks like you failed 1 test of 1.

#   Failed test 'return error when broken JSON'
#   at t/transport/jsonp-send.t line 91.
# Looks like you failed 1 test of 7.
t/transport/jsonp-send.t ..... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/7 subtests 
...

    #   Failed test at t/transport/xhr-send.t line 85.
    #     Structures begin differing at:
    #          $got->[0] = '204'
    #     $expected->[0] = '500'
    # Looks like you failed 1 test of 1.

#   Failed test 'return error when broken JSON'
#   at t/transport/xhr-send.t line 91.
# Looks like you failed 1 test of 6.
t/transport/xhr-send.t ....... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/6 subtests 

I suspect that this is caused by JSON::XS 4.00

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.