无法使用 AS3 连接到 java 服务器

发布于 2024-10-22 01:53:16 字数 1667 浏览 6 评论 0原文

我在使用 AS3 中的 XMLSocket 脚本时遇到问题。我有一个 java 服务器,我正在尝试发送 XML 数据,但服务器没有收到任何内容。最令人惊讶的是我的脚本一个月前运行得很好,现在我的 IOError 监听器返回给我:

“Error #2031: Socket error. URL: 127.0.0.1 在测试() 在 Client_fla::MainTimeline/frame1()”

和我的 SecurityError 侦听器:

“错误 #2048:安全沙箱违规:file:///C|/Documents%20and%20Settings/Zeph/Bureau/Client.swf 无法从中加载数据127.0.0.1:18000。 在测试() 在 Client_fla::MainTimeline/frame1()"

我尝试更改 IP,我在另一台计算机上尝试,我尝试拉取脚本的前一个版本,该版本没有更改,但没有结果。

我只是不明白为什么它停止了这是我的脚本:

package
{

    import flash.net.XMLSocket;
    import flash.events.*;
    import flash.display.MovieClip;

    public class test extends MovieClip 
    {

        public function test()
        {
            trace("pouet");
            var xmlsock:XMLSocket = new XMLSocket(); 
            xmlsock.connect("127.0.0.1", 18000);
            var xmlFormattedData = new XML('<message pseudo="Nix" value="Coucou !"/>'); 
            xmlsock.send(xmlFormattedData);
            xmlsock.addEventListener(DataEvent.DATA, onData);
            xmlsock.addEventListener(IOErrorEvent.IO_ERROR, ioerror);
            xmlsock.addEventListener(SecurityErrorEvent.SECURITY_ERROR, secuerror);
            xmlsock.send(xmlFormattedData);

        }

        private function onData(event:DataEvent):void 
        { 
            trace("[" + event.type + "] " + event.data); 
        }


        private function ioerror(event:IOErrorEvent):void 
        { 
        trace(event);
        }

        private function secuerror(event:SecurityErrorEvent):void 
        { 
        trace(event);
        }

    }

}

我对此很生气,有人有想法吗?

感谢您的阅读!

I'm having trouble with a XMLSocket script in AS3. I have a java server and i'm trying to send a XML data, but the server isn't recieving anything. The most suprising is that my script worked very well a month ago, and now my IOError listener returns me :

"Error #2031: Socket error. URL: 127.0.0.1
at test()
at Client_fla::MainTimeline/frame1()"

and my SecurityError listener :

"Error #2048: Security Sandbox violation : file:///C|/Documents%20and%20Settings/Zeph/Bureau/Client.swf cannot load data from 127.0.0.1:18000.
at test()
at Client_fla::MainTimeline/frame1()"

I tried to change IP, I tried on another computer, I tried to pull a former version of my script, which was unchanged, with no result.

I just can't understand why it stopped working like this. Here is my script :

package
{

    import flash.net.XMLSocket;
    import flash.events.*;
    import flash.display.MovieClip;

    public class test extends MovieClip 
    {

        public function test()
        {
            trace("pouet");
            var xmlsock:XMLSocket = new XMLSocket(); 
            xmlsock.connect("127.0.0.1", 18000);
            var xmlFormattedData = new XML('<message pseudo="Nix" value="Coucou !"/>'); 
            xmlsock.send(xmlFormattedData);
            xmlsock.addEventListener(DataEvent.DATA, onData);
            xmlsock.addEventListener(IOErrorEvent.IO_ERROR, ioerror);
            xmlsock.addEventListener(SecurityErrorEvent.SECURITY_ERROR, secuerror);
            xmlsock.send(xmlFormattedData);

        }

        private function onData(event:DataEvent):void 
        { 
            trace("[" + event.type + "] " + event.data); 
        }


        private function ioerror(event:IOErrorEvent):void 
        { 
        trace(event);
        }

        private function secuerror(event:SecurityErrorEvent):void 
        { 
        trace(event);
        }

    }

}

I'm getting mad with this, does anyone have an idea?

Thanks for reading!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖上的星空 2024-10-29 01:53:16

该错误表明,您正在从本地文件系统运行 Flash 应用程序,并且该应用程序想要发出网络请求(到您的 Java 服务器)。

默认情况下不允许这样做。您可以执行以下两种操作之一:

  • 更新 Flash Player 中的全局安全设置(右键单击、高级设置、全局安全设置,然后将 Flash 文件或整个文件夹设置为允许执行网络请求)

  • 从网络服务器运行您的 Flash 应用程序(并确保 crossdomain.xml 在 java 服务器上就位)。

the error suggests, that you are running a flash application from your local file system and this application wants to make a network request (to your java server).

This is not allowed by default. You can do one of two things:

  • Update your Global Security Settings in your flash player (right click, advanced settings, global security settings, then set the flash file or the whole folder to be allowed to do network requests)

  • Run your flash application from a webserver (and make sure, that a crossdomain.xml is in place on the java server).

知你几分 2024-10-29 01:53:16

正如您的错误所示,您遇到了沙箱安全违规。这意味着 Flash 不允许使用来自除自身应用程序域之外的应用程序域的资源。基本上有两个修复,一个比另一个简单得多:

  1. 阅读如何创建和加载 跨域 xml。这只是您正在运行的 Flash 应用程序读取的服务器上的一个“策略”。正确设置可能很棘手,但这是普遍接受的路线。

  2. 在输出设置的“本地播放安全”下,您可以选中“访问网络文件”,而不是“仅访问本地文件” - 并快速解决您的问题。

希望有帮助!

As your error is indicating, you're experiencing a sandbox security violation. This means that Flash won't allow assets from application domains other than its own. There are basically two fixes, one much simpler than the other:

  1. Read up on how to create and load crossdomain xml. This is simply a "policy" on the server that your running flash application reads. It can be tricky to set up correctly, but this is the generally accepted route.

  2. On your output settings, under "local playback security" you may be able to check "access network files", instead of "access local files only" - and solve your problem quickly.

Hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文