manually inject data into a site object
I have a web service written in twisted-web. I have it running behind a NAT. I have a component (based on twisted Protocol) that makes a connection out from behind the NAT to a relay. Let's call this ReverseThing. Web clients can connect to the relay to send data back over this ReverseThing. Once I receive the data, how can I inject it directly into the web service? Assume both these services run in the same twisted process. Here's what I've tried: I can pass in the Site object to the ReverseThing protocol, so that I can call p=buildProtocol() on it, then I can call dataReceived() manually on that p. But obviously this doesn't work, because there isn't really a transport object to call things like getPeer() on. Is there some other way to send data to a Site, without it actually coming over the wire? Thanks, Gary
On Dec 26, 2011, at 5:48 PM, gary jefferson wrote:
I have a web service written in twisted-web.
I have it running behind a NAT.
I have a component (based on twisted Protocol) that makes a connection out from behind the NAT to a relay. Let's call this ReverseThing.
Since you're mentioning Twisted and NAT, I feel obliged to direct your attention to Vertex, which sorta solves some of these problems but badly needs a maintainer: http://pypi.python.org/pypi/Vertex It may not be relevant to your use-case though (and isn't relevant to your question at all).
Web clients can connect to the relay to send data back over this ReverseThing.
Once I receive the data, how can I inject it directly into the web service? Assume both these services run in the same twisted process.
Here's what I've tried: I can pass in the Site object to the ReverseThing protocol, so that I can call p=buildProtocol() on it, then I can call dataReceived() manually on that p. But obviously this doesn't work, because there isn't really a transport object to call things like getPeer() on.
You must call makeConnection(transport) on a Protocol before you call dataReceived. So make a Transport object - you don't need a "real" one that represents a socket, just something that implements
Is there some other way to send data to a Site, without it actually coming over the wire?
You're 90% of the way there already, and you have the right idea :). -glyph
participants (2)
-
gary jefferson
-
Glyph