[Twisted-Python] ProxyClient error using ReverseProxy
David McCurley
David.McCurley at technologist.com
Fri Jul 25 19:11:24 MDT 2003
I'm working on full reverse proxy functionality and have run into an
error (twisted 1.0.6) during some basic testing.
SYNOPSIS:
- Made a root ReverseProxyResource that goes to google from
http://localhost:8080/ in my web.tap
- Using Mozilla 1.4, hit the local url, all is okay
- Now click the refresh button and an exception is thrown in the console
window running the tap.
- Reload again and no error, reload again and exception, repeatable
every other time.
I'm not clear on the full call details but the refresh that causes the
exception has a request already queued, so when the
ProxyClient.handleRequest calls the self.father.transport.loseConnection
method, the exception triggers because the transport is a
StringTransport in the queued request and it doesn't have a
"loseConnection" method.
I've been trying to trace this to submit a patch, but its not clear to
me what the queuing is for or why this is happening, or when to call
loseConnection.
DETAILS:
Made an .rpy file and a web tap that made it the root resource:
t1.rpy
===========================
import twisted.web.proxy
resource = twisted.web.proxy.ReverseProxyResource('www.google.com', 80,
'')
===========================
In mozilla 1.4 get http://localhost:8080/
Console output:
====================
2003/07/25 19:03 EDT [HTTPChannel,0,127.0.0.1] Starting factory
<twisted.web.proxy.ProxyClientFactory instance at 0x840eccc>
2003/07/25 19:03 EDT [ProxyClient,client] Stopping factory
<twisted.web.proxy.ProxyClientFactory instance at 0x840eccc>
2003/07/25 19:03 EDT [HTTPChannel,1,127.0.0.1] Starting factory
<twisted.web.proxy.ProxyClientFactory instance at 0x8416fb4>
====================
Now click reload after a few seconds (Mozilla icon stays spinning this
time like it has an open connection its waiting on):
Console output:
====================
2003/07/25 19:04 EDT [HTTPChannel,1,127.0.0.1] Starting factory
<twisted.web.proxy.ProxyClientFactory instance at 0x8411b3c>
2003/07/25 19:04 EDT [ProxyClient,client] Traceback (most recent call
last):
File
"/usr/lib/python2.2/site-packages/twisted/internet/default.py", line
472, in doSelect
_logrun(selectable, _drdw, selectable, method, dict)
File "/usr/lib/python2.2/site-packages/twisted/python/log.py",
line 65, in callWithLogger
callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python2.2/site-packages/twisted/python/log.py",
line 52, in callWithContext
return context.call({ILogContext: newCtx}, func, *args,
**kw)
File
"/usr/lib/python2.2/site-packages/twisted/python/context.py", line 32,
in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File
"/usr/lib/python2.2/site-packages/twisted/internet/default.py", line
481, in _doReadOrWrite
why = getattr(selectable, method)()
File
"/usr/lib/python2.2/site-packages/twisted/internet/tcp.py", line
216, in doRead
return self.protocol.dataReceived(data)
File
"/usr/lib/python2.2/site-packages/twisted/protocols/basic.py", line 184,
in dataReceived
return self.rawDataReceived(data)
File
"/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 354,
in rawDataReceived
self.handleResponseEnd()
File
"/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 336,
in handleResponseEnd
self.handleResponse(b)
File "proxy.py", line 72, in handleResponse
File
"/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 285,
in __getattr__
return getattr(self.__dict__['s'], attr)
exceptions.AttributeError: loseConnection
2003/07/25 19:04 EDT [ProxyClient,client] Stopping factory
<twisted.web.proxy.ProxyClientFactory instance at 0x8411b3c>
====================
Reload again and this time the following output happens at the console
and the Mozilla icon stops spinning like all connections are closed.
Console output:
====================
2003/07/25 19:04 EDT [HTTPChannel,2,127.0.0.1] Starting factory
<twisted.web.proxy.ProxyClientFactory instance at 0x84266ac>
2003/07/25 19:04 EDT [ProxyClient,client] Stopping factory
<twisted.web.proxy.ProxyClientFactory instance at 0x84266ac>
2003/07/25 19:04 EDT [HTTPChannel,3,127.0.0.1] Starting factory
<twisted.web.proxy.ProxyClientFactory instance at 0x84454a4>
====================
Reload again and it starts spinning and gives same type of exception
trace as above.
Any pointers on where to look or how to fix this?
Thanks,
David
More information about the Twisted-Python
mailing list