带有 gevent-websocket 的策略服务器
正在尝试让 gevent-websocket 正常工作,但它没有连接到我的闪存规范策略服务器。我的policy.py如下:
from gevent.server import StreamServer
policy = """<?xml version="1.0" encoding="UTF-8"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
</cross-domain-policy>\0"""
def handle(sock, address):
s = sock.makefile()
while True:
msg = s.readline()
if not msg:
print("Client disconnected (%s:%s)" % address)
break
else:
sock.sendall(policy)
print("Client connected, served policy (%s:%s)" % address)
server = StreamServer(('0.0.0.0', 843), handle)
server.serve_forever()
但是使用websocket我得到:
[WebSocket] policy file: xmlsocket://localhost:843
[WebSocket] cannot connect to Web Socket server at ws://localhost:8065 (SecurityError: Error #2048) make sure the server is running and Flash socket policy file is correctly placed
[WebSocket] close
working on trying to get gevent-websocket working and it's not connecting to my policy server for the flash specification. My policy.py is as follows:
from gevent.server import StreamServer
policy = """<?xml version="1.0" encoding="UTF-8"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
</cross-domain-policy>\0"""
def handle(sock, address):
s = sock.makefile()
while True:
msg = s.readline()
if not msg:
print("Client disconnected (%s:%s)" % address)
break
else:
sock.sendall(policy)
print("Client connected, served policy (%s:%s)" % address)
server = StreamServer(('0.0.0.0', 843), handle)
server.serve_forever()
Yet with websocket I'm getting:
[WebSocket] policy file: xmlsocket://localhost:843
[WebSocket] cannot connect to Web Socket server at ws://localhost:8065 (SecurityError: Error #2048) make sure the server is running and Flash socket policy file is correctly placed
[WebSocket] close
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
readline() 方法在这里不起作用,因为 Flash 发送一个
'\0'
,该消息不以换行符终止。试试这个而不是
readline()
:the readline() method won't work here, because Flash sends a
'<policy-file-request/>\0'
which is not terminated by newline.Try this instead of
readline()
: