[Twisted-web] reactor.listenSSL() question

vitaly at synapticvision.com vitaly at synapticvision.com
Tue Apr 21 14:54:03 EDT 2009


Examples of both, client and server, were taken from  
http://twistedmatrix.com/projects/core/documentation/examples/#auto2

Now, what I've change on server side is instead of <A> to use <B>:

<A>:
factory = Factory()
factory.protocol = Echo

<B>:
from pyamf.remoting.gateway.twisted import TwistedGateway
from pyamf.remoting.gateway import expose_request

gateway = TwistedGateway({ "controller": FlexInterface() },  
expose_request=False, authenticator=None)
root = resource.Resource()
root.putChild('', gateway)

The client side(echoclient_ssl.py) is working fine with <A>, but for  
<B> always return 400.


:-))



Quoting "Jean-Paul Calderone" <exarkun at divmod.com>:

> On Tue, 21 Apr 2009 13:47:06 -0400, vitaly at synapticvision.com wrote:
>> Hi,
>> I'm trying to make work the following client/server, but the
>> server always return: HTTP/1.1 400 Bad Request.
>
> You seem to be connecting something which is not an HTTP client to an
> HTTP server.  So the HTTP server complains because what is being sent
> to it is not an HTTP request.
>
>> [snip - setup]
>>     reactor.listenSSL(8050, server.Site(root), ServerContextFactory())
>>     reactor.run()
>>
>
> There's your HTTP server.
>
>> [snip - imports]
>> class EchoClient(LineReceiver):
>>     end="Bye-bye!"
>>     def connectionMade(self):
>>         self.sendLine("Hello, world!")
>>         self.sendLine("What a fine day it is.")
>>         self.sendLine(self.end)
>> [snip - more stuff]
>>     factory = EchoClientFactory()
>>
>>     reactor.connectSSL('localhost', 8050, factory,
>> ssl.ClientContextFactory(), timeout=3)
>>     reactor.run()
>
> And there's your client - something which isn't going to send HTTP
> requests to the server it connects to.
>
> So a 400 response is precisely what you should expect here. :)
>
> Jean-Paul
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>





More information about the Twisted-web mailing list