Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   Серверные технологии и Flash (http://www.flasher.ru/forum/forumdisplay.php?f=62)
-   -   Security error 2048 (http://www.flasher.ru/forum/showthread.php?t=183891)

justforquestion 04.09.2012 15:16

Security error 2048
 
Здравствуйте. Пишу на AS 3 подключение к серверу.

Код подключения

Код AS3:

package 
{
        import flash.display.Sprite;
        import flash.events.*;
        import flash.media.Sound;
        import flash.net.*;
        import flash.system.Security;
        import flash.external.ExternalInterface;
 
        public class MessengerGateInterface extends Sprite
        {
                private var bsocket:Socket;
                private var host:String;
                private var port:Number;
 
                public function MessengerGateInterface():void
                {       
                        Security.allowDomain("our.domain.com");
                        Security.allowInsecureDomain("our.domain.com");
                        Security.loadPolicyFile("http://our.domain.com/crossdomain.xml");
 
                        this.bsocket = new Socket();
 
                        this.bsocket.addEventListener(Event.CONNECT, this.onConnect);
                        this.bsocket.addEventListener(Event.CLOSE, this.onClose);
 
                        this.bsocket.addEventListener(ProgressEvent.SOCKET_DATA, this.dataHandler);
                        this.bsocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.securityError)
                        this.bsocket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
 
                        this.setSettings("our.domain.com", 4434);
                        this.connect();
 
                        ExternalInterface.call("initGate");
                }
 
                public function securityError(event:SecurityErrorEvent):void
                {
                        ExternalInterface.call("onSecurityError", event.toString()+" " + Security.REMOTE.toString());
                        trace("Security error");
                }
 
                public function setSettings(host:String,port:Number): void
                {
                        this.host = host;
                        this.port = port;
                }
 
                public function connect(): void
                {
                        this.bsocket.connect(this.host, this.port);
                }
 
                public function onConnect(event:Event): void
                {
                        if (this.bsocket.connected) {
                                ExternalInterface.call("successConnection");
                                trace("success connection");
                        }
                }
 
                public function onClose(event:Event): void
                {
                        this.bsocket.close();
                        ExternalInterface.call("onCloseConnection");
                }
 
                public function dataHandler(e:ProgressEvent): void { 
                        if (bsocket.bytesAvailable>0) {
                                ExternalInterface.call("receiveFromServer",bsocket.readUTFBytes(bsocket.bytesAvailable));
                                trace("receive data");
                        }
                }
 
                public function ioErrorHandler(event:IOErrorEvent):void
                {
                        ExternalInterface.call("errorConnection");
                        trace("error connection");
                }
 
                private function init(e:Event = null):void
                {
                        new MessengerGateInterface();
                }
        }
}

Код crossdomain.xml
Сам файл лежит в корне сайта our.domain.com
Код:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="our.domain.com" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

Фрагмент сервера
QString data = QString(clientConnection->readAll());

Код:

  if(data == "<policy-file-request/>"){
      QString answer = QString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\"><cross-domain-policy><site-control permitted-cross-domain-policies=\"all\"><allow-access-from domain=\"our.domain.com\" to-ports=\"*\"/><allow-http-request-headers-from domain=\"*\" headers=\"*\"/></cross-domain-policy>");
        clientConnection->write(answer.toStdString().c_str());
        echo("Send Policy Data");
        return;
  }

Генерируется ошибка:
Цитата:

Security Error #2048
В чем может быть проблема? Как решить?

Zebestov 04.09.2012 17:58

Мы анекдоты и ошибки по номерам не запоминаем, хорошо бы привести текст.

caseyryan 04.09.2012 18:32

В том, что сокетам пофиг ваш кроссдоменник. Сокет сервер должен отдавать файл через порт
Код AS3:

Security.loadPolicyFile("xmlsocket://server.com:2525");

http://help.adobe.com/ru_RU/ActionSc...0204-7c60.html


Часовой пояс GMT +4, время: 21:09.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.