autobahn.twisted.websocket IPv6

五迷三道 提交于 2019-12-23 04:46:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!