air 2.6 serversocket and actionscript 3 socket connection

房东的猫 提交于 2019-12-25 04:09:58

问题


I have written a server application in AIR 2.6. I use the ServerSocket class for the server side and the client side is written in actionscript 3 and uses the Socket class. When I connect the client to server with local IP (127.0.0.1 or 192.168.0.2), I get this message: <policy-file-request/>. I then send my policy file to client from server and connection is successfully.

However, when i connect client to server with my global IP (IP assigned by my ISP), I get the same policy file request message but the connection cannot be established. Ports are opened (843, 4444 and 5555) but still no luck. My policy file is as follows:

< ?xml version="1.0"?>< !DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">< cross-domain-policy>< site-control permitted-cross-domain-policies="master-only"/>< allow-access-from domain="*" to-ports="*" />< /cross-domain-policy>

I have variable with string type, that equals this policy+String.fromCharCode(0).

Any help would be greatly appreciated.


回答1:


Check your router settings and ensure that the local machine which is running the server has sufficient network privileges to establish the connection in the first place. The easiest way to do this is to find the DMZ setting in your router config and add the IP address of your server machine. I'm not sure that this is the issue though, because you stated that you still receive the policy request over the socket... which is puzzling. However, at present time with the details that you have provided all I can do really is make an educated guess and at this point, DMZ sounds like the most probable cause.

Also note that in your domain policy you really should not (in production code) allow ANY client to connect over ANY socket. That defeats the entire purpose of the security model. Anyway that is the best answer I can give with the current information. I'll also recommend reading this article by Adobe about dealing with ServerSocket and client connections.

http://www.adobe.com/devnet/air/flex/quickstart/articles/communicating_with_sockets.html#articlecontentAdobe_numberedheader_3



来源:https://stackoverflow.com/questions/9638800/air-2-6-serversocket-and-actionscript-3-socket-connection

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