def run_autobahn_server(host="127.0.0.1", port=9003):
    """
    Runs a Autobahn server on Python 2.x
    """
    from twisted.internet import reactor
    from autobahn.twisted.websocket import WebSocketServerProtocol, \
        WebSocketServerFactory
        
    class MyServerProtocol(WebSocketServerProtocol):
        def onMessage(self, payload, isBinary):
            self.sendMessage(payload, isBinary)

    logger = logging.getLogger('autobahn_testsuite')
    logger.warning("Serving Autobahn server on %s:%s" % (host, port))
    
    factory = WebSocketServerFactory("ws://%s:%d" % (host, port))
    factory.protocol = MyServerProtocol

    reactor.listenTCP(port, factory)
    reactor.run()
dataset/ETHPy150Open Lawouach/WebSocket-for-Python/test/autobahn_test_servers.py/run_autobahn_server/original