[Twisted-web] Implementing a continuous polling client in twisted

Daniel Gonzalez gonvaled at gonvaled.com
Mon Aug 8 14:00:51 EDT 2011


Hello,

I am trying to implement a continuous polling client for couchdb change
notifications, which uses HTTP protocol (REST):

http://guide.couchdb.org/draft/notifications.html

I have started by using the agent described here:
http://twistedmatrix.com/documents/current/web/howto/client.html

This is working fine, but the problem is that the connection is not
permanent: it is being closed after a timeout (I think 1 minute).
For continuous polling, I need to keep the connection open (forever), or if
that is not possible, to reconnect as soon as the connection is closed.

I have taken a look at the code, and the problem seems to be that the Agent
(twisted/web/client.py) class is using ClientCreator
(twisted/internet/protocol.py)
ClientCreator is not doing reconnection. I would like to implement a similar
class to ClientCreator, but one which uses ReconnectingClientFactory
(twisted/internet/protocol.py)

I have not found any guidance in using ReconnectingClientFactory. According
to the documentation:

"Note that clients should call my resetDelay method after they
have connected successfully."

The difficulty I have is that the factory is not returning any deferred
which I could use to catch when connections are established, and then call
the resetDelay method.

Do you have any pointers to examples of use of ReconnectingClientFactory?

BR,
Daniel Gonzalez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20110808/7fd52c23/attachment.htm 


More information about the Twisted-web mailing list