makamaka / AnyEvent-PocketIO-Client

6 stars 2 forks source link

cannot connect to socketio server #1

Open chenryn opened 11 years ago

chenryn commented 11 years ago

I can see onopen being callback. When I print Dumper $, I see session_id too. But then client.pl got "message is reserved event." and nothing else. Why?

My server was built with Juggernaut.And my html/js work right.

bluet commented 11 years ago

Could you give some more informations? (console message / debug message / environment / etc)

chenryn commented 11 years ago

sorry but how to get 'console/debug message' about this? the url of Juggernaut I found in Chrome is like 'ws://ip:port//socket.io/1/websocket/sid', I thougt its same as other?

bluet commented 11 years ago

Could you show your code? It seems that maybe you set a event callback with a reserved name. According to https://github.com/makamaka/AnyEvent-PocketIO-Client/blob/master/lib/AnyEvent/PocketIO/Client.pm#L13 and https://github.com/makamaka/AnyEvent-PocketIO-Client/blob/master/lib/AnyEvent/PocketIO/Client.pm#L122 you cannot overwrite them.

$self->reg_event('foo' => sub {

...

            });
chenryn commented 11 years ago

https://gist.github.com/4134446 基本上就是照着POD的例子写的吧

bluet commented 11 years ago

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

如果試試第二種,能正常運作嗎?How about the second example?

    use PocketIO::Client::IO;
    my $socket =

PocketIO::Client::IO->connect("http://localhost:3000/");

    my $cv = AnyEvent->condvar;
    my $w  = AnyEvent->timer( after => 5, cb => $cv );

    $socket->on( 'message', sub {
        say $_[1];
    } );

    $socket->on( 'connect', sub {
        $socket->send('Parumon!');
        $socket->emit('hello', "perl");
    } );

    $cv->wait;

另外我想作者是日本人,應該看不懂中文,所以還是要有英文讓作者知道我們的討 論才好。:-) BTW, I think the author is from Japan who's not familiar with Chinese, so we'd better discuss in English so he can understand what we're talking about. :-)

On 2012年11月23日 16:01, chenryn wrote:

https://gist.github.com/4134446 基本上就是照着POD的例子写的吧

— Reply to this email directly or view it on GitHub https://github.com/makamaka/AnyEvent-PocketIO-Client/issues/1#issuecomment-10651863.


/ Just another [ Perl | FOSS | Security ] Hacker. / / BlueT = Matthew Lien = 練喆明 / / http://BlueT.org / / GPG: 4A293CBD / -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlCvM60ACgkQvRNvgEopPL2PDACfddxTrxdDf+ngR9qQws+Tg1OC xQkAn044hDgUKmlMWCS42bG+zXfR/v4E =Gfee -----END PGP SIGNATURE-----

chenryn commented 11 years ago

I'm not sure about the different of send and emit in client.Exit with nothing after 5 second by just paste example codes. Seem like it didn't connect to my url 'http://$server:$port'?

2012/11/23 BlueT - Matthew Lien - 練喆明 notifications@github.com

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

如果試試第二種,能正常運作嗎?How about the second example?

use PocketIO::Client::IO; my $socket = PocketIO::Client::IO->connect("http://localhost:3000/");

my $cv = AnyEvent->condvar; my $w = AnyEvent->timer( after => 5, cb => $cv );

$socket->on( 'message', sub { say $_[1]; } );

$socket->on( 'connect', sub { $socket->send('Parumon!'); $socket->emit('hello', "perl"); } );

$cv->wait;

另外我想作者是日本人,應該看不懂中文,所以還是要有英文讓作者知道我們的討 論才好。:-) BTW, I think the author is from Japan who's not familiar with Chinese, so we'd better discuss in English so he can understand what we're talking about. :-)

On 2012年11月23日 16:01, chenryn wrote:

https://gist.github.com/4134446 基本上就是照着POD的例子写的吧

— Reply to this email directly or view it on GitHub < https://github.com/makamaka/AnyEvent-PocketIO-Client/issues/1#issuecomment-10651863 .


/ Just another [ Perl | FOSS | Security ] Hacker. / / BlueT = Matthew Lien = 練喆明 / / http://BlueT.org / / GPG: 4A293CBD / -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlCvM60ACgkQvRNvgEopPL2PDACfddxTrxdDf+ngR9qQws+Tg1OC xQkAn044hDgUKmlMWCS42bG+zXfR/v4E =Gfee -----END PGP SIGNATURE-----

— Reply to this email directly or view it on GitHubhttps://github.com/makamaka/AnyEvent-PocketIO-Client/issues/1#issuecomment-10652813.

bluet commented 11 years ago

run a PocketIO server on your machine, then use the code following codes to test. Anything show on your screen?

use AnyEvent; use feature 'say'; use PocketIO::Client::IO;

my $socket = PocketIO::Client::IO->connect("http://localhost:5000/");

my $cv = AnyEvent->condvar;

$socket->on( 'connect', sub { say 'Connected' } );

$cv->wait;

makamaka commented 11 years ago

Sorry for the delay in my response.

As BlueT said, "message is reserved event." comes from trying to overwrite the reserved name. Would you modify your code like the following code?


my $cv = AnyEvent->condvar;

$client->on('message' => sub { print STDERR "get message : $_[1]\n"; $cv->end; # <--- notify for blocking });

$client->handshake( $server, $port, sub { my ( $error, $self, $sesid, $hb_timeout, $contimeout, $trans ) = @; $client->open( 'websocket' => sub { $client->send("$channel"); } ); } );

$cv->wait;

chenryn commented 11 years ago

Got 'Open timeout.' for BlueT's code and 'Not yet connected.' for makamaka's code. But I can got right '1::','2::'... if I run the Mojo::UserAgent script similar to example in POD.

bluet commented 11 years ago

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Where are you connecting to? Any public site or your own server? (and could you provide your server code?)

On 2012年11月27日 19:08, chenryn wrote:

Got 'Open timeout.' for BlueT's code and 'Not yet connected.' for makamaka's code. But I can got right '1::','2::'... if I run the Mojo::UserAgent script similar to example in POD.

— Reply to this email directly or view it on GitHub https://github.com/makamaka/AnyEvent-PocketIO-Client/issues/1#issuecomment-10753961.


/ Just another [ Perl | FOSS | Security ] Hacker. / / BlueT = Matthew Lien = 練喆明 / / http://BlueT.org / / GPG: 4A293CBD / -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlC0smkACgkQvRNvgEopPL10HACgj9NBxpKuMc13kgPcwNTMuw0N KEEAn0eoXgKs7ad3EvhbxDixyykteTkn =RXAY -----END PGP SIGNATURE-----

chenryn commented 11 years ago

Run juggernaut on my own server. https://github.com/maccman/juggernaut Nothing to configure, just run command and then public message to redis