Can someone please point out what I'm doing wrong here?

Here is my basic Server:

class MockObject(object):
    """
    Mock object
    """
    def __init__(self): pass

class MockService(SlaveService):
    exposed_obj = MockObject()

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    log = logging.getLogger("mylogger")
    server = ThreadedServer(MockService,
                            hostname='',
#                            hostname='127.0.0.1',
#                            hostname='localhost',
                            port=18812)
    server.start()

All give the following message at startup:

root@ciroc% python rpyc_server_bug.py
INFO:MOCK/18812:server started on [127.0.0.1]:18812


However, when I use this code to connect:

import logging
import rpyc
import sys       # For redirecting server stdout to ours

logging.basicConfig()
log = logging.getLogger("mylogger")

# Create a connection to the RE server
conn = rpyc.classic.connect("server_name", port=18812)

# Show serve output on our terminal
conn.modules.sys.stdout = sys.stdout

I can only get a successful connection when I use the hostname='' version 
in the server.
If I set hostname to 'localhost' or '127.0.0.1' in "ThreadedServer", I get 
the following error from the connection code:

root@server_name% ipython rpyc_connect_bug.py
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (100, 0))

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)

/mnt/jstokes_src/dev/me/jde2/rpyc_tests_3/rpyc_connect_bug.py in <module>()
     12 conn = rpyc.classic.connect("server_name",
     13                             port=18812,
---> 14                             ipv6=False)
     15 
     16 # Show serve output on our terminal

/opt/lib/python2.7/site-packages/rpyc-3.2.2-py2.7.egg/rpyc/utils/classic.pyc 
in connect(host, port, ipv6)
     63     :returns: an RPyC connection exposing ``SlaveService``
     64     """
---> 65     return factory.connect(host, port, SlaveService, ipv6 = ipv6)
     66 
     67 def ssl_connect(host, port = DEFAULT_SERVER_SSL_PORT, keyfile = 
None,

/opt/lib/python2.7/site-packages/rpyc-3.2.2-py2.7.egg/rpyc/utils/factory.pyc 
in connect(host, port, service, config, ipv6)
     87     :returns: an RPyC connection
     88     """
---> 89     s = SocketStream.connect(host, port, ipv6 = ipv6)
     90     return connect_stream(s, service, config)
     91 

/opt/lib/python2.7/site-packages/rpyc-3.2.2-py2.7.egg/rpyc/core/stream.pyc 
in connect(cls, host, port, **kwargs)
    112         if kwargs.pop("ipv6", False):
    113             kwargs["family"] = socket.AF_INET6
--> 114         return cls(cls._connect(host, port, **kwargs))
    115 
    116     @classmethod

/opt/lib/python2.7/site-packages/rpyc-3.2.2-py2.7.egg/rpyc/core/stream.pyc 
in _connect(cls, host, port, family, socktype, proto, timeout, nodelay)
     90         s = socket.socket(family, socktype, proto)
     91         s.settimeout(timeout)
---> 92         s.connect((host, port))
     93         if nodelay:
     94             s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

/opt/lib/python2.7/socket.pyc in meth(name, self, *args)
    222 
    223 
--> 224 
    225 
    226 

error: [Errno 61] Connection refused


Can anyone please provide some insights?

Thanks,
jas


Reply via email to