I am currently building a Flex application with a PHP backend. The flex application should talk to the backend using Zend_AMF.
I have implemented the Zend_AMF endpoint as a controller, so it is accessible via http://localhost/myapp/amf.
I am trying to test the service using a service browser called ZamfBrowser.
When connecting, I get this error:
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"
开发者_JS百科 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"
I have tried googling for a solution, but can't seem to find any reasons that will cause that error. I have checked the php code with display_errors turned on, and there were no errors.
If I visit my endpoint in a browser, I get a prompt to save a application/amf file. Opening it showed Zend Amf Endpoint.
I am at lost as to what else can be causing the error.
Any ideas appreciated.
Edit: Some php code. I am simply implementing Zend_AMF in a controller
class AmfController extends BaseController{
public function __construct(){
$server = new Zend_Amf_Server();
$server->setProduction(false);
$server->setClass( 'ZendAmfServiceBrowser' );
ZendAmfServiceBrowser::setAmfServer($server);
echo($server->handle());
}
}
Edit: Charles. I tried using Charles with the windows proxy turned on, but it does not seem to capture anything from ZamfBrowser.
If I visit the endpoint from a rowser, I get prompted to save a file (the amf message). Here is the charles output:
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
The Raw output (Which could not be decoded as 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>
For Zend_AMF users, NetConnection.Call.BadVersion
almost always means that you're not sending back AMF. Sometimes it's because you have an errant echo
before you output the AMF, sometimes it's because you're getting an error in your PHP code and it's spitting out the backtrace, or sometimes it's not sending anything back at all. In cases like these I'll use a packet sniffer like Packetyzer on Windows or Cocoa Packet Analyzer on Mac OS X to see what is being sent back. You can also use PHP output buffers to collect all output and save it to a file for examination instead of using a packet sniffer.
Without seeing any code, I'm not sure, but I wonder about the object encoding of your net connection?
import flash.net.NetConnection; import flash.net.ObjectEncoding; // Set AMF version for AMFPHP var netConnection:NetConnection; netConnection.objectEncoding = ObjectEncoding.AMF0; // instead of AMF3
I don't know anything about ZendAMF, but in BlazeDS you get the BadVersion
error typically when you try to mix'n'match http
and https
.
精彩评论