[Twisted-Python] getObjectAtSSL: client just hangs
Ruslan Spivak
alienoid at is.lg.ua
Mon Jul 21 16:17:33 MDT 2003
Hello!
I found patch to spread.pb, so that there is no exception , but now my
client just hangs with no response.
Here is the simple server:
from twisted.spread import pb
from twisted.internet import app, reactor
from OpenSSL import SSL
class ServerContextFactory:
def getContext(self):
"""Create an SSL context.
This is a sample implementation that loads a certificate from a file
called 'server.pem'."""
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_certificate_file('server.pem')
ctx.use_privatekey_file('server.pem')
return ctx
class Server(pb.Root):
def __init__(self):
self.client = None
def checkpoint(self):
self.client.callRemote("printClientMsg", "Hello from
Server.checkpoint")
reactor.callLater(2, self.checkpoint)
def remote_printServerMsg(self, client, msg):
print "Server got: %s" % msg
self.client = client
client.callRemote("printClientMsg", "Hello from
Server.printServerMsg")
reactor.callLater(2, self.checkpoint)
if __name__ == "__main__":
appl = app.Application("pbtest")
appl.listenSSL(33333, pb.BrokerFactory(Server()),
ServerContextFactory())
appl.run()
Heres is client pbclient.py:
from twisted.spread import pb
from twisted.internet import reactor
class ClientCall(pb.Referenceable):
def remote_printClientMsg(self, msg):
print "Client: %s" % msg
def got_obj(obj, c):
obj.callRemote("printServerMsg", c, "Hello from Client")
c = ClientCall()
def1 = pb.getObjectAtSSL("localhost", 33333, 30)
def1.addCallback(got_obj, c)
reactor.run()
Your help is very appreciated. Thanks in advance.
Best regards,
Ruslan
More information about the Twisted-Python
mailing list