pydle: Failure to reconnect

I’m using client.run in the asyncio branch, and after a short period of being connected, I’m encountering:

Encountered error on socket.
TimeoutError: Ping timeout: no data received from server in 180 seconds.
Unexpected disconnect. Attempting to reconnect.

after which the memory for the process jumps from ~15 MB to ~2 GB. This seems to be because on_data is triggered constantly with empty bytestrings. It’s possible this is a result of handle_forever continuing after the connection is disconnected. I’m not sure what’s causing the initial ping timeout though. I’m using a program that was running properly with the master branch, and just converted it by adding async’s and await’s to overrides and calls of functions that were converted into coroutines and by using client.run instead of client.connect and client.handle_forever

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 35 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Something to note is that the server may not necessarily send a PING within every PING_TIMEOUT seconds if the client has been active. Perhaps an alternative solution is to PING the server before going through with the client disconnect to verify that the server has stopped communicating with the client.

e.g. change https://github.com/Shizmob/pydle/blob/master/pydle/client.py#L170 to

# pause for delay - 1 seconds
await sleep(delay - 1)
# attempt to PING server
await self.raw('PING\r\n')
await sleep(1)
# then continue

there is, Client.on_disconnect(expected:bool)