jaraco / irc

Full-featured Python IRC library for Python.
MIT License
392 stars 86 forks source link

irc.client : ping timeout with keepaplive enabled #72

Closed romainFan3466 closed 8 years ago

romainFan3466 commented 8 years ago

Hi, Here is the script that I use using irc.client, only to listen my server :

def listen_to(connection):
soc = connection.socket
buf = ''
while connection.is_connected():
    buf += soc.recv(1024).decode("utf-8")
    print(buf)

def main():
    args = parse_args()
    port = args.port
    nickname = args.nickname
    target = args.channel
    server = args.host
    password = None if not args.password else args.password

reactor = irc.client.Reactor()

try:
    c = reactor.server()
    c.connect(server, port, nickname,password=password)

    c.join(target)
    c.set_keepalive(5)

    listen_to(c)

except irc.client.ServerConnectionError:
    print(sys.exc_info()[1])
    raise SystemExit(1)

reactor.process_forever()

if __name__ == '__main__':
main()

I read the old issues, and found out a set_keepalive was added, but my server still close the connection after the ping time runs out ( ping timeout). I try to explore the library, and changed ping time from my ircd-hybridserver, the same error appears :

PING : irc.XXXXXXX.com
ERROR :Closing Link: i.love.debian.org (Ping timeout: 40 seconds)

Thanks for your help, you made an excellent job !

romainFan3466 commented 8 years ago

Sorry, I apologize, I forgot to wrap the listen_to() function into a thread, otherwise it run out into an infinite loop and process_forever is never executed

jaraco commented 8 years ago

Glad it's working for you!