{"action":"created","issue":{"url":"https://api.github.com/repos/jaraco/irc/issues/16","labels_url":"https://api.github.com/repos/jaraco/irc/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/jaraco/irc/issues/16/comments","events_url":"https://api.github.com/repos/jaraco/irc/issues/16/events","html_url":"https://github.com/jaraco/irc/issues/16","id":118054742,"number":16,"title":"IRC Client - Ping Timeout Issue","user":{"login":"jaraco","id":308610,"avatar_url":"https://avatars.githubusercontent.com/u/308610?v=3","gravatar_id":"","url":"https://api.github.com/users/jaraco","html_url":"https://github.com/jaraco","followers_url":"https://api.github.com/users/jaraco/followers","following_url":"https://api.github.com/users/jaraco/following{/other_user}","gists_url":"https://api.github.com/users/jaraco/gists{/gist_id}","starred_url":"https://api.github.com/users/jaraco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaraco/subscriptions","organizations_url":"https://api.github.com/users/jaraco/orgs","repos_url":"https://api.github.com/users/jaraco/repos","events_url":"https://api.github.com/users/jaraco/events{/privacy}","received_events_url":"https://api.github.com/users/jaraco/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-20T14:42:08Z","updated_at":"2015-11-20T14:42:09Z","closed_at":"2015-11-20T14:42:08Z","body":"I am trying to use this library for IRC client things for a small IRC bot I'm writing. However, I've found that it always disconnects from a \"Ping Timeout\" and can't figure out why this is happening or how to prevent it from happening.\n\nLibrary version: 8.0.1\nPython version: 2.7.3\nIRC Server: irc.quakenet.org:6667\n\nI first tried incorporating the library in my own code based on the irccat.py example. However, I get the same issue with just running the irccat.py script, although I modified it to hard-code the third argument. It works perfectly until it's idle for 5-10 minutes at which point it disconnects from a ping timeout. I added a printout to the on_disconnect global handler and it's not called when the ping timeout occurs. I also tried adding a global handler for \"ping\", but that was never called either.\n\nLet me know if there's anything I'm missing or if you need any more info. Thanks!\n\n----------------------------------------\n- Bitbucket: https://bitbucket.org/jaraco/irc/issue/16\n- Originally reported by: Anonymous\n- Originally created at: 2013-04-01T01:35:51.590\n"},"comment":{"url":"https://api.github.com/repos/jaraco/irc/issues/comments/158418947","html_url":"https://github.com/jaraco/irc/issues/16#issuecomment-158418947","issue_url":"https://api.github.com/repos/jaraco/irc/issues/16","id":158418947,"user":{"login":"jaraco","id":308610,"avatar_url":"https://avatars.githubusercontent.com/u/308610?v=3","gravatar_id":"","url":"https://api.github.com/users/jaraco","html_url":"https://github.com/jaraco","followers_url":"https://api.github.com/users/jaraco/followers","following_url":"https://api.github.com/users/jaraco/following{/other_user}","gists_url":"https://api.github.com/users/jaraco/gists{/gist_id}","starred_url":"https://api.github.com/users/jaraco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaraco/subscriptions","organizations_url":"https://api.github.com/users/jaraco/orgs","repos_url":"https://api.github.com/users/jaraco/repos","events_url":"https://api.github.com/users/jaraco/events{/privacy}","received_events_url":"https://api.github.com/users/jaraco/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T14:42:08Z","updated_at":"2015-11-20T14:42:08Z","body":"I think i may need more info on this issue. Or maybe I can help with the issue. By default, the [irc object sets up a global responder for pings](/jaraco/irc/src/4bd700350c143a74cae3f95be18409c6915a34fb/irc/client.py?at=default#cl-187). If the 'ping' handler isn't being called, that probably means that the event loop isn't being activated properly.\n\nOne critical aspect of the event-driven style is that IRC.process_once must be called periodically. In this case, irccat and irccat2 are bad examples. They initially call process_forever (via start), which will repeatedly call process_once. However, in their on_welcome or on_join handlers, they enter a loop that runs until input is exhausted (and process_once will not be called again). Thus the ping responder will never be called, and if the connection is idle, the server will disconnect the client with a ping timeout.\n\nFurthermore, I don't think on_disconnect will ever be called either, since there's nothing to handle the disconnect message.\n\nIt's possible your code is subject to this same issue. I believe testbot might have better behavior.\n\nIn any case, that's food for thought. I can still do some more testing and plan to in the future, but for now, that's one possible avenue you might consider.\n\n----------------------------------------\nOriginal comment by: Jason R. Coombs\n"}}