Zend_Amf Channel.Connect.Failed错误NetConnection.Call.BadVersion

时间:2011-07-14 04:28:05

标签: php flex amf

我目前正在使用PHP后端构建Flex应用程序。 flex应用程序应该使用Zend_AMF与后端通信。

我已将Zend_AMF端点实现为控制器,因此可以通过http://localhost/myapp/amf访问它。

我正在尝试使用名为ZamfBrowser的服务浏览器测试服务。

连接时,我收到此错误:

There was an error loading the server's info.  Error: (mx.rpc.events::FaultEvent)#0
  bubbles = false
  cancelable = true
  currentTarget = (mx.rpc.remoting.mxml::RemoteObject)#1
    channelSet = (mx.messaging::ChannelSet)#2
      authenticated = false
      channelIds = (Array)#3
        [0] (null)
      channels = (Array)#4
        [0] (mx.messaging.channels::AMFChannel)#5
          authenticated = false
          channelSets = (Array)#6
          connected = false
          connectTimeout = -1
          enableSmallMessages = true
          endpoint = "http://localhost/myapp/amf"
          failoverURIs = (Array)#7
          id = (null)
          mpiEnabled = false
          netConnection = (flash.net::NetConnection)#8
            client = (mx.messaging.channels::AMFChannel)#5
            connected = false
            maxPeerConnections = 8
            objectEncoding = 3
            proxyType = "none"
            uri = "http://localhost/myapp/amf"
          piggybackingEnabled = false
          polling = false
          pollingEnabled = true
          pollingInterval = 3000
          protocol = "http"
          reconnecting = false
          recordMessageSizes = false
          recordMessageTimes = false
          requestTimeout = -1
          uri = "http://localhost/myapp/amf"
          url = "http://localhost/myapp/amf"
          useSmallMessages = false
      clustered = false
      connected = false
      currentChannel = (mx.messaging.channels::AMFChannel)#5
      heartbeatInterval = 0
      initialDestinationId = (null)
      messageAgents = (Array)#9
        [0] (mx.rpc::AsyncRequest)#10
          authenticated = false
          autoConnect = true
          channelSet = (mx.messaging::ChannelSet)#2
          clientId = (null)
          connected = false
          defaultHeaders = (null)
          destination = "AMF"
          id = "D8377B12-6625-6224-9ADD-26CFA97594DC"
          priority = -1
          reconnectAttempts = 0
          reconnectInterval = 0
          requestTimeout = -1
          subtopic = ""
    concurrency = "multiple"
    convertParametersHandler = (null)
    convertResultHandler = (null)
    destination = "AMF"
    endpoint = "http://localhost/myapp/amf"
    getServices = (mx.rpc.remoting.mxml::Operation)#11
      argumentNames = (Array)#12
      arguments = (Object)#13
      concurrency = "multiple"
      lastResult = (null)
      makeObjectsBindable = true
      name = "getServices"
      operationManager = (null)
      properties = (null)
      resultElementType = (null)
      resultType = (null)
      service = (mx.rpc.remoting.mxml::RemoteObject)#1
      showBusyCursor = true
    makeObjectsBindable = true
    managers = (null)
    operations = (Object)#14
      getServices = (mx.rpc.remoting.mxml::Operation)#11
    requestTimeout = -1
    showBusyCursor = true
    source = "ZendAmfServiceBrowser"
  eventPhase = 2
  fault = (mx.rpc::Fault)#15
    content = (Object)#16
    errorID = 0
    faultCode = "Client.Error.MessageSend"
    faultDetail = "Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://localhost/myapp/amf'"
    faultString = "Send failed"
    message = "faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://localhost/myapp/amf''"
    name = "Error"
    rootCause = (mx.messaging.events::ChannelFaultEvent)#17
      bubbles = false
      cancelable = false
      channel = (mx.messaging.channels::AMFChannel)#5
      channelId = (null)
      connected = false
      currentTarget = (mx.messaging.channels::AMFChannel)#5
      eventPhase = 2
      faultCode = "Channel.Connect.Failed"
      faultDetail = "NetConnection.Call.BadVersion: : url: 'http://localhost/myapp/amf'"
      faultString = "error"
      reconnecting = false
      rejected = false
      rootCause = (Object)#18
        code = "NetConnection.Call.BadVersion"
        description = ""
        details = ""
        level = "error"
      target = (mx.messaging.channels::AMFChannel)#5
      type = "channelFault"
  headers = (null)
  message = (mx.messaging.messages::ErrorMessage)#19
    body = (Object)#16
    clientId = (null)
    correlationId = "60935430-9E15-0B99-3D33-26CFA976D93E"
    destination = ""
    extendedData = (null)
    faultCode = "Client.Error.MessageSend"
    faultDetail = "Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://localhost/myapp/amf'"
    faultString = "Send failed"
    headers = (Object)#20
    messageId = "BDB90F14-D0D5-FAFF-6A6C-26CFA9DE9C02"
    rootCause = (mx.messaging.events::ChannelFaultEvent)#17
    timestamp = 0
    timeToLive = 0
  messageId = "BDB90F14-D0D5-FAFF-6A6C-26CFA9DE9C02"
  statusCode = 0
  target = (mx.rpc.remoting.mxml::RemoteObject)#1
  token = (mx.rpc::AsyncToken)#21
    message = (mx.messaging.messages::RemotingMessage)#22
      body = (Array)#23
      clientId = (null)
      destination = ""
      headers = (Object)#24
      messageId = "60935430-9E15-0B99-3D33-26CFA976D93E"
      operation = "getServices"
      source = "ZendAmfServiceBrowser"
      timestamp = 0
      timeToLive = 0
    responders = (null)
    result = (null)
  type = "fault"

我已经尝试使用Google搜索解决方案,但似乎无法找到导致该错误的任何原因。我已经检查了启用了display_errors的php代码,并且没有错误。

如果我在浏览器中访问我的端点,则会收到保存应用程序/ amf文件的提示。打开它显示了Zend Amf Endpoint。

我很遗憾还有什么可能导致错误。

任何想法都赞赏。

编辑:一些PHP代码。我只是在控制器中实现Zend_AMF

class AmfController extends BaseController{

   public function __construct(){
      $server = new Zend_Amf_Server();
      $server->setProduction(false);

      $server->setClass( 'ZendAmfServiceBrowser' );
      ZendAmfServiceBrowser::setAmfServer($server);
      echo($server->handle());
   }

}
编辑:查尔斯。我尝试使用Charles打开windows代理,但它似乎没有从ZamfBrowser捕获任何内容。

如果我从rowser访问端点,系统会提示我保存文件(amf消息)。以下是查尔斯的输出:

GET /myapp/www/amf HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Cookie: SESSb4604b0fcf7c7bac0da8afac2a88b017=JxMrgUUT0rl6RnLAR3emeX9gaI_Dikm3DJ4oF2TW2vQ

原始输出(无法解码为AMF):

HTTP/1.1 200 OK
Date: Thu, 14 Jul 2011 06:15:10 GMT
Server: Apache/2.2.17 (Win32) mod_fcgid/2.3.6
X-Powered-By: PHP/5.3.6
Cache-Control: no-cache, must-revalidate
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/x-amf

<p>Zend Amf Endpoint</p>

3 个答案:

答案 0 :(得分:1)

对于Zend_AMF用户,NetConnection.Call.BadVersion几乎总是意味着您没有发回AMF。有时这是因为你在输出AMF之前有一个错误的echo,有时候是因为你的PHP代码中出现错误并且它正在吐出回溯,或者有时它根本没有发回任何东西。在这些情况下,我将在Windows上使用Packetyzer之类的数据包嗅探器或在Mac OS X上使用Cocoa Packet Analyzer来查看正在发回的内容。您还可以使用PHP输出缓冲区来收集所有输出并将其保存到文件中进行检查,而不是使用数据包嗅探器。

答案 1 :(得分:0)

没有看到任何代码,我不确定,但我想知道你的网络连接的对象编码?

    import flash.net.NetConnection;
    import flash.net.ObjectEncoding;

    // Set AMF version for AMFPHP
    var netConnection:NetConnection;
    netConnection.objectEncoding = ObjectEncoding.AMF0; // instead of AMF3

答案 2 :(得分:0)

我对ZendAMF一无所知,但在BlazeDS中,当您尝试混合'{'BadVersionhttp时,您会收到https错误。