我有与 Redis 持续连接的 Twisted 服务器。我正在使用库https://github.com/fiorix/txredisapi。
问题是 Twisted 有时会失去与 Redis 的连接并在不久后重新连接。我不知道为什么。在我的本地机器和在线 VPS 上都发生了同样的事情。
日志:
2013-04-12 11:25:34+0200 [RedisProtocol,client] <twisted.internet.tcp.Connector instance at 0xf6c45d4c> will retry in 10 seconds
2013-04-12 11:25:34+0200 [RedisProtocol,client] Stopping factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:25:45+0200 [-] Starting factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:30:47+0200 [RedisProtocol,client] <twisted.internet.tcp.Connector instance at 0xf6c45d4c> will retry in 10 seconds
2013-04-12 11:30:47+0200 [RedisProtocol,client] Stopping factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:30:58+0200 [-] Starting factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:35:59+0200 [RedisProtocol,client] <twisted.internet.tcp.Connector instance at 0xf6c45d4c> will retry in 10 seconds
2013-04-12 11:35:59+0200 [RedisProtocol,client] Stopping factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:36:10+0200 [-] Starting factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:41:12+0200 [RedisProtocol,client] <twisted.internet.tcp.Connector instance at 0xf6c45d4c> will retry in 8 seconds
2013-04-12 11:41:12+0200 [RedisProtocol,client] Stopping factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 11:41:21+0200 [-] Starting factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
它整天整夜都在发生,我的日志很快就变大了。
当 redis 断开时有人连接时记录:
2013-04-12 12:29:58+0200 [HTTPPageGetter,client] Unhandled error in Deferred:
2013-04-12 12:29:58+0200 [HTTPPageGetter,client] Unhandled Error
Traceback (most recent call last):
Failure: lib.txredisapi.txredisapi.ConnectionError: Not connected
2013-04-12 12:30:03+0200 [-] Starting factory <lib.txredisapi.txredisapi.RedisFactory instance at 0xf6c45ccc>
2013-04-12 12:30:22+0200 [Protocol,20,89.73.182.51] Connection from 89.73.182.51:38635 closed. Code: 1006, Reason: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)