Closed julien-c closed 11 years ago
First, please bear in mind that this repo hasn't seen an official release yet and should still be considered alpha software. There will probably be bugs and I may have to ask you to trace through the code yourself or provide me with a replicable test case to assist you further.
Per RFC 1459 Section 4.6.2, the server should be PING commands at regular intervals, but the standard is unspecific about the length of these intervals. It's difficult to say why you wouldn't be receiving PING events. I wouldn't worry to much about this unless your connection is frequently timing out.
Offhand, I can't see what you might be doing wrong. Can you provide more information? Are you connecting to Freenode, or a different network? What version of PHP are you using? Are you adding any listeners other than the one you've shown above?
Thank for your help!
I'm connecting to Freenode from PHP 5.4.10. The whole actual code is this Laravel 4 app repo. The command to run from the root of the app is php artisan irc:log
.
The strange thing is that I'm responding to PINGs correctly, if I don't auto-join. In other words, either one listener or the other seems to work.
Here's a log when doing only PONGs: https://gist.github.com/julien-c/5088764 Here's one when trying to do both: https://gist.github.com/julien-c/5088777 – The command just hangs after auto-joining, and times out after a few minutes.
I was thinking maybe I had to flush writing to a stream or something. Or maybe it's because I have another connection to Freenode from the same IP (but I guess it shouldn't be).
Do you think I'd be better off setting up a full-blown Phergie for the time being?
Thanks again!
By the way, off topic, but I had to submit to Packagist in order to be able to install from composer: https://packagist.org/packages/phergie/phergie-irc-client-react – I've just added you as maintainer, hope it's ok!
@julien-c don't submit packages you don't own. never ever. always use a vcs repo instead.
@igorw Ok, but I'm curious why?
Because that is the job of the package maintainer. He has control over the package. If you want something to be added to packagist, ask the maintainer to do it.
a) maybe there was a reason why the package was not on packagist. possibly it is not in a usable state yet.
b) you are now listed as a maintainer on packagist.
Ok, points taken – apologies. The repo's Readme says "The recommended method of installation is through composer" so I guessed it was just an oversight, but you're right, you never know.
I've deleted the package from Packagist, @elazar feel free to add it back.
@julien-c As @igorw pointed out, I hadn't added this repo to Packagist yet because it's not in what I would consider to be a stable state. I've only done rudimentary practical testing on it as of yet and no unit tests have been written. Once I've made satisfactory progress in those areas, I'll release version 1.0.0. I do appreciate you taking the initiative, though; no harm done. :)
If you're looking to get a more stable bot working sooner, then I'd recommend using http://github.com/phergie/phergie for the time being. This repo is only intended to provide a very basic and minimal client library; it won't serve as a full-blown replacement for Phergie 2. Such a replacement will come eventually, but it may be a while. All the work I do on Phergie is in my spare time, of which I have very little, so progress is generally slow and in spurts. I appreciate you checking this repo out, though, and I will try to look further into your issue this evening. Thank you for the debugging details.
@julien-c I'm afraid I'm unable to replicate your issue.
This standalone test script:
<?php
require_once 'vendor/autoload.php';
use Phergie\Irc\Connection;
use Phergie\Irc\Client\React\Client;
$connection = new Connection;
$connection->setServerHostname('irc.freenode.net');
$connection->setUsername('Elazar');
$connection->setHostname('irc.freenode.net');
$connection->setServername('irc.freenode.net');
$connection->setRealname('Matthew Turland');
$connection->setNickname('Phergie3');
$client = new Client;
$client->addConnection($connection);
$client->addListener(function($message, $write, $connection, $logger) {
// Ping Pong:
if ($message['command'] === 'PING') {
$write->ircPong('phergie3-test');
}
});
$client->addListener(function($message, $write, $connection, $logger) {
// Auto-join:
if (isset($message['code']) && in_array($message['code'], array('RPL_ENDOFMOTD', 'ERR_NOMOTD'))) {
$write->ircJoin('#phergie3');
}
});
$client->run();
produces this output, which indicates that both event handlers are working:
2013-03-05 18:30:44 DEBUG USER Elazar irc.freenode.net irc.freenode.net :Matthew Turland
2013-03-05 18:30:44 DEBUG NICK :Phergie3
2013-03-05 18:30:44 DEBUG :sendak.freenode.net NOTICE * :*** Looking up your hostname...
2013-03-05 18:30:44 DEBUG :sendak.freenode.net NOTICE * :*** Checking Ident
2013-03-05 18:30:44 DEBUG :sendak.freenode.net NOTICE * :*** Found your hostname
2013-03-05 18:30:49 DEBUG :sendak.freenode.net NOTICE * :*** No Ident response
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 001 Phergie3 :Welcome to the freenode Internet Relay Chat Network Phergie3
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 002 Phergie3 :Your host is sendak.freenode.net[193.219.128.49/6667], running version ircd-seven-1.1.3
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 003 Phergie3 :This server was created Mon Dec 31 2012 at 23:37:24 EET
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 004 Phergie3 sendak.freenode.net ircd-seven-1.1.3 DOQRSZaghilopswz CFILMPQbcefgijklmnopqrstvz bkloveqjfI
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 005 Phergie3 CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQcgimnprstz CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode KNOCK STATUSMSG=@+ CALLERID=g :are supported by this server
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 005 Phergie3 CASEMAPPING=rfc1459 CHARSET=ascii NICKLEN=16 CHANNELLEN=50 TOPICLEN=390 ETRACE CPRIVMSG CNOTICE DEAF=D MONITOR=100 FNC TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: :are supported by this server
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 005 Phergie3 EXTBAN=$,arx WHOX CLIENTVER=3.0 SAFELIST ELIST=CTU :are supported by this server
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 251 Phergie3 :There are 197 users and 77804 invisible on 31 servers
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 252 Phergie3 30 :IRC Operators online
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 253 Phergie3 1 :unknown connection(s)
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 254 Phergie3 42790 :channels formed
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 255 Phergie3 :I have 4039 clients and 1 servers
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 265 Phergie3 4039 4819 :Current local users 4039, max 4819
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 266 Phergie3 78001 87783 :Current global users 78001, max 87783
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 250 Phergie3 :Highest connection count: 4820 (4819 clients) (463976 connections received)
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 375 Phergie3 :- sendak.freenode.net Message of the Day -
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Welcome to sendak.freenode.net in Vilnius, Lithuania, EU.
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Thanks to Microlink Lietuva (http://www.microlink.lt) for providing this
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- server!
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- SENDAK, MAURICE [1928-2012]. The author of Seven Little
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Monsters and Where the Wild Things Are, Maurice Sendak was
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- born in Brooklyn, NY, US, to a family of poor Polish
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- immigrants who moved to the US before World War II. He
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- became an illustrator while in high school.
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- You're using freenode, a service of Peer-Directed Projects
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Center Ltd (http://freenode.net/pdpc.shtml).
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- By connecting to freenode you indicate that you have read
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- and agree to adhere to our policies and procedures as per
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- the website (http://freenode.net). We would like to remind
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- you that unauthorized public logging of channels on the
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- network is prohibited. Public channel logging should only
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- take place where the channel owner(s) has requested this
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- and users of the channel are all made aware (if you are
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- publically logging your channel, you may wish to keep a
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- notice in topic and perhaps as a on-join message).
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- freenode runs an open proxy scanner. Your use of the network
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- indicates your acceptance of this policy. For details on
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- freenode network policy, please take a look at our policy
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- page (http://freenode.net/policy.shtml). Thank you for using
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- the network!
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Don't forget to check out these other Peer-Directed Projects:
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- FOSSCON [http://www.fosscon.org] and fossevents
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- [http://www.fossevents.org], and soon we'll repeat last years
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- success with Picnics for Geeks across the globe, more info at
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- [http://geeknic.org]
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- freenode is a service of Peer-Directed Projects Center Ltd,
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- a not for profit organisation registered in England and Wales.
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Thank you for using freenode!
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :-
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- ***************************************************************
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- Please read http://blog.freenode.net/2010/11/be-safe-out-there/
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 372 Phergie3 :- ***************************************************************
2013-03-05 18:30:49 DEBUG :sendak.freenode.net 376 Phergie3 :End of /MOTD command.
2013-03-05 18:30:49 DEBUG JOIN :#phergie3
2013-03-05 18:30:49 DEBUG :Phergie3 MODE Phergie3 :+i
2013-03-05 18:30:56 DEBUG :Phergie3!~Elazar@ip184-189-95-47.lf.br.cox.net JOIN #phergie3
2013-03-05 18:30:56 DEBUG :sendak.freenode.net MODE #phergie3 +ns
2013-03-05 18:30:56 DEBUG :sendak.freenode.net 353 Phergie3 @ #phergie3 :@Phergie3
2013-03-05 18:30:56 DEBUG :sendak.freenode.net 366 Phergie3 #phergie3 :End of /NAMES list.
2013-03-05 18:31:11 DEBUG :Elazar!~matt@ip184-189-95-47.lf.br.cox.net JOIN #phergie3
2013-03-05 18:31:16 DEBUG :Elazar!~matt@ip184-189-95-47.lf.br.cox.net PRIVMSG #phergie3 :test
2013-03-05 18:33:21 DEBUG PING :sendak.freenode.net
2013-03-05 18:33:21 DEBUG PONG :phergie3-test
Can you please try executing a similar standalone script that exists apart from the rest of your code, just to rule out the possibility that any code external to this library is contributing to your issue?
@elazar Thanks for your help. This does work, however just changing the channel from #phergie3
to #laravel
causes the same hanging: no message (PINGs, user messages, etc.) is ever received after joining.
OK, I am able to replicate your issue for that channel. Sample console output:
2013-03-06 07:13:57 DEBUG :gibson.freenode.net 376 Phergie3 :End of /MOTD command.
2013-03-06 07:13:57 DEBUG JOIN :#laravel
2013-03-06 07:13:57 DEBUG :Phergie3 MODE Phergie3 :+i
2013-03-06 07:14:03 DEBUG :Phergie3!~Elazar@ip184-189-95-47.lf.br.cox.net JOIN #laravel
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 332 Phergie3 #laravel :Official Laravel IRC || Current Versions: Laravel 3.2.13, Laravel 4 Beta 3 || Laravel 4 Beta docs http://four.laravel.com || Need help? Please use http://paste.laravel.com to show your code, errors, and work || http://laravel.com/docs || http://forums.laravel.io || Laracon Talk Videos: http://www.youtube.com/LaravelScreencasts
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 333 Phergie3 #laravel JasonLewis!~JasonLewi@110.145.253.9 1362467030
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 353 Phergie3 = #laravel :Phergie3 ryan_tait freeed Lilly mynameis wodKa gamer13 dbpolito Ziggy` Spikes MindSpark rextan Shealan aebersold BeingTomGreen pats_Toms Simon[in]MUC mterenzio StevenWoodson huglester|work mkz drale2k dannewns orkz bullen chadtomkiss sojic Bulk Darsain gerardrocha superdo ec30 codetroll micflan durehed Krek mupkoo jeroengerits mitchellvanw davehewy bpierre safetysteve dnstbr shokora |Daz| dawid-office ajaypatel JonoB asher^ rchavik driesvints Perp done
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 353 Phergie3 = #laravel :FrenkyNet|work niall_obrien Oddman|ZzZzZzz Jakee`_ abumirqaan glsee xoron bartzy @PhillSparks b1rkh0ff Vainoharhainen CornishPasty Vedol duellsy PaulSimpson Kindari jeremeamia Robbo_ laax Carsekyx nickstr SuRfDeMoN alexwhitman andjtd2 @daylerees robbkore kenren niels__ emelce Pateno ytsejam DeXTeD Keika mooseware speilberg0 Bung55 AntonioRibeiro bwl pav_z lemoncode egersdorfer DanielO shutch akcx dvl` mkoppel2040 Jorijn sqwk Robbo_ph EPIK WonderSlug k_89
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 353 Phergie3 = #laravel :ccovey|work zz_wgolden atno eth grumpyOldRussian netorious delewis nicholasruunu codeM0nK3Y introspectr3 Che-Anarc ccovey exaem htmelvis jporcel MichMich_ spib cor_vi quantax- caseydriscoll Rosix cmwelsh martxel Codemonkey joni|ZNC Blaster Shammy dresfdez Meroje rhuk Meztek jonphipps|away wildstrangething lyonscf JeffCost +Rommie XoneFobic[work] Volstvok alexnilsson moogblob Gerben boris_ oso96_2000 GaryJ|away Sythic sebek laCour Darkimmortal w|zzy
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 353 Phergie3 = #laravel :oohnoitz raulp clone1018 ColKilke1ny schwame dazz w00fz coolazura mpajor_o15 Smo- johnhamelink_ jpf_ Nesci kolor99 davzie stigchristian glamb kbanman enberg jozan b00st`work steadweb @daylerees|work jesta_ gnarf _scott tplaner pauldunn resmo mgb Stuba Addow Weust` WesleyL sync0pate spacemud cahva @machuga|away subliminal Franss el2ro dalys dev_ trq mygan jyggen Snicers-Work2 matzipan _druu jmartinez adrinavarro Wintereise davedevelopment Kaabi naquad
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 353 Phergie3 = #laravel :CrazyyMaxx prawnsalad zz_JesseObrien hooch Svpernova09 iiro Akufen Dragory sCoRpi Sypher|NL FrostyX Kamal_ Ashe hasker k0rnel_ @ChanServ citricsquid xsbeats scalabl3 Kolin MichMich|Home sl0ppy Dan9186 awc737_away trumpeter2003 Lucashayes ryduh D-Boy l4rva Danielss89_
2013-03-06 07:14:03 DEBUG :gibson.freenode.net 366 Phergie3 #laravel :End of /NAMES list.
2013-03-06 07:14:03 DEBUG :ChanServ!ChanServ@services. NOTICE Phergie3 :[#laravel] Welcome to the official IRC home of Laravel
At that point, the bot doesn't output any further events, e.g. when I successfully join the channel using a separate client. Generally I haven't had issues having multiple clients join the same network from the same LAN, so I wouldn't think that would be the problem. I'll try to investigate further later on tonight.
I found the source of the issue by adding a debugging prompt for $data
to src/Phergie/Irc/Client/React/ReadStream.php
. That results in this output before logging stops, which indicates that the parser isn't able to parse it successfully:
:services. 328 Phergie3 #laravel :http://laravel.com
The reason for this is that services.
was not a valid hostname by the parser's definition. I asked around in #freenode-seven and the consensus seems to be that 1) I'm wrong and this is standard-compliant; or 2) even if I'm right, there's no real point in treating the hostname as anything other than a label.
I've committed a fix: phergie/phergie-irc-parser@685a6fb77b55511f377414a7ee507126497349e8. If you run composer update
on your local clone, you should get it. Thanks again for reporting this issue. Please let me know if this patch doesn't resolve it for you.
It does! Thanks a ton Matthew. I'll leave the script running for a few days on that channel to see if anything else breaks it.
I might be the first one to use this lib in production, exciting! :)
Hmm, no, actually I've got another use case that crashes the parser (Undefined offset: 0 in Irc/Parser.php line 379
), on this message:
:julien-c!~julien-c@tru75-6-82-240-32-161.fbx.proxad.net PART #laravel
I guess I'll open another issue in the parser's repo and I'll try to debug it myself.
Thanks! :)
Hi,
I'm looking to implement a simple IRC logger on top of
phergie-irc-client-react
.So that I can keep connected, I've tried implemented PingPong and Auto-join, that way:
However, I can join the channel, but then I don't get PING commands. Additionnally, I'm not seeing any messages with actual posted content from any channel.
Any idea what I'm doing wrong here?
Best,
Julien