Flash - HTTP 请求在本地主机上不起作用

发布于 2024-09-06 01:23:28 字数 1629 浏览 6 评论 0原文

首先,我试图修复一些我一开始就没有构建的东西,项目的负责人向我保证,当他离开时,它工作得很好,尽管自从他离开后我从未接触过的版本似乎已经同样的问题。一般来说,我对编程也有点陌生,所以如果我在第一篇文章中遗漏了重要信息,请告诉我,我会尝试添加更多信息。

我有一个在线托管的 Flash 应用程序,它充当用 Delphi 编写的服务器应用程序的客户端。大多数通信都是使用套接字完成的,它工作得很好。上传数据文件和下载结果文件是使用 HTTP 请求完成的,只要用户使用另一台计算机上的服务器实例,这些请求就可以正常工作。但是,如果用户在自己的计算机上安装了服务器应用程序并尝试使用它并指定 localhost 作为 url,则套接字通信仍然可以工作,但 HTTP 请求却不能。

所有基于套接字的通信都工作正常,并且当它不在本地主机上时,所有 HTTP 请求也工作正常,这就是为什么这对我来说如此神秘。我尝试将服务器发送的闪存跨域策略文件更改为完全宽松,所有端口,所有域,所有http请求标头,但仍然没有运气。

Flash 应用程序将在大多数时间无限期地等待本地主机,直到我关闭服务器应用程序,然后给出此错误消息:

Error #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security sandbox violation: http://abcde.com/Testing.swf cannot load data from http://localhost:2188/guid=53D569A8-56EA-4AC2-BDA0-2F43525E1378.

我尝试将其托管在多台计算机上,每台计算机都可以很好地访问另一台计算机上的实例,但赢了当它尝试使用自己的实例时不起作用。

另外,如果我简单地输入 http://localhost:2188/guid=53D569A8- 56EA-4AC2-BDA0-2F43525E1378 在网络浏览器中,我试图获取的结果文件弹出得很好。

以下是 Flash 应用程序中尝试下载该文件的代码块:

private function downloadFile():void
{
    trace("downloadFile: " + this.guid + " from " + this.server.URL);
    fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    fileRef.addEventListener(ProgressEvent.PROGRESS, downloadProgressHandler);
    var ur:URLRequest = new URLRequest("http://" + _server.URL + ":" + _server.port);
    ur.url += "/guid=" + _guid;
    ur.method = URLRequestMethod.GET;
    fileRef.download(ur, _filename);
    _downloadStart = true;
}

如果有人有任何见解,我将不胜感激,因为我在这里完全没有想法。

First off, I'm trying to fix something that I didn't build to begin with and the guy who's project it was assures me it was working fine when he left, although a version I haven't touched since he left seems to have the same issues. I'm also a bit new to programming in general so let me know if I've left out important information in my first post and I will try to add more info.

I have a flash application hosted on-line that acts as a client for a server application written in Delphi. Most of the communication is done using sockets, which work fine. Uploading data files and downloading results files is done using HTTP requests, which work fine as long as the user is making use of an instance of the server on another computer. However, if the user has the server application installed on their own computer and attempts to use it specifying localhost as the url, the socket communication still works, but the HTTP requests don't.

All the socket based communication works fine and, when it is not on the localhost, all the HTTP requests work fine as well, which is why this is so mystifying to me. I've tried changing the flash cross-domain policy file that the server dispatches to be completely permissive, all ports, all domains, all http-request-headers, and still no luck.

The Flash app will sit waiting for localhost indefinitely most of the time until I close the server application, and then give this error message:

Error #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security sandbox violation: http://abcde.com/Testing.swf cannot load data from http://localhost:2188/guid=53D569A8-56EA-4AC2-BDA0-2F43525E1378.

I've tried hosting it on multiple computers, each machine can access the instance on another just fine, but won't work when it tries to work with its own instance.

Also, if I simply put http://localhost:2188/guid=53D569A8-56EA-4AC2-BDA0-2F43525E1378 in to a web browser, the results file I am trying to get pops up just fine.

Here's the chunk of code in the flash app that attempts to download the file:

private function downloadFile():void
{
    trace("downloadFile: " + this.guid + " from " + this.server.URL);
    fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    fileRef.addEventListener(ProgressEvent.PROGRESS, downloadProgressHandler);
    var ur:URLRequest = new URLRequest("http://" + _server.URL + ":" + _server.port);
    ur.url += "/guid=" + _guid;
    ur.method = URLRequestMethod.GET;
    fileRef.download(ur, _filename);
    _downloadStart = true;
}

If anyone has any insight at all, I would be grateful because I am completely out of ideas here.

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

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

发布评论

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

评论(1

眼前雾蒙蒙 2024-09-13 01:23:28

这是 Flash 播放器安全模型的限制。要解决此问题,您可以将闪存打包为 AIR 应用程序,并取消其中许多安全限制。

如果您将 Flash 文件托管在 Web 服务器上而不是在本地访问 .swf,您也可能会取得更好的成功。

您无法执行的另一件事是从 Flash 播放器访问本地文件,这是您可以使用 AIR 运行时执行但无法在 Flash 播放器中执行的操作的另一个示例。

This is a limitation of the flash player's security model. To get around this problem, you can package your flash as an AIR application and have many of these security restrictions lifted.

You may also have better success if you host your flash file on a web server instead of accessing the .swf locally.

Another thing that you won't be able to do is access local files from the flash player, this is another example of something you can do with the AIR runtime that you cannot do in the flash player.

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