问题
I use autobahn framework to create a websocket server in python.
I use the following code
url = "ws://0.0.0.0:" + str(server_port)
ServerFactory = MyServerFactory
factory = ServerFactory(url,
debug = True,
debugCodePaths = True)
factory.protocol = MyServerFactory
factory.setProtocolOptions(requireMaskedClientFrames = False, applyMask = True)
listenWS(factory)
reactor.run()
I need to accept connections not only on IP4 but IPv6 as well.
In the same code I create a HTTP server using the following code:
ad = MyWebAdmin()
ad.server = ServerFactory
web = Site(ad)
web.log = lambda _: None # disable annoyingly verbose request logging
reactor.listenTCP(options.webport, web)
And it can listen to both IPv4 & IPv6 sockets.
来源:https://stackoverflow.com/questions/29970402/autobahn-twisted-websocket-ipv6