问题
I searched through the internet and any answer for this error could not solved my problem.
I have a blazeds server in Openshift and I'm connecting to it via Flash Builder. I want to make an app that will send a message to all other users who are using my app.
I mean I have 2 applications. One will send a message to server and this one will be on Desktop, the other one is a mobile project and will receive messages that I sent from desktop app through server.
I tried to use BlazeDS messaging but it's giving me this error:
(mx.messaging.messages::ErrorMessage)#0
body = (Object)#1
clientId = (null)
correlationId = "96461BC6-7288-A95C-923B-B32FCDDC9CE3"
destination = ""
extendedData = (null)
faultCode = "Client.Error.MessageSend"
faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://ainApp.swf/messagebroker/amfpolling'"
faultString = "Send failed"
headers = (Object)#2
messageId = "147C1B6F-6877-79D8-3BCA-B32FCDF5E3F9"
rootCause = (mx.messaging.events::ChannelFaultEvent)#3
bubbles = false
cancelable = false
channel = (mx.messaging.channels::AMFChannel)#4
authenticated = false
channelSets = (Array)#5
connected = false
connectTimeout = -1
enableSmallMessages = true
endpoint = "http://ainApp.swf/messagebroker/amfpolling"
failoverURIs = (Array)#6
id = "my-polling-amf"
mpiEnabled = false
netConnection = (flash.net::NetConnection)#7
client = (mx.messaging.channels::AMFChannel)#4
connected = false
httpIdleTimeout = 0
maxPeerConnections = 8
objectEncoding = 3
proxyType = "none"
uri = "http://ainApp.swf/messagebroker/amfpolling"
piggybackingEnabled = false
polling = false
pollingEnabled = true
pollingInterval = 4000
protocol = "http"
reconnecting = false
recordMessageSizes = false
recordMessageTimes = false
requestTimeout = -1
uri = "http://{server.name}:{server.port}/messagebroker/amfpolling"
url = "http://{server.name}:{server.port}/messagebroker/amfpolling"
useSmallMessages = false
channelId = "my-polling-amf"
connected = false
currentTarget = (mx.messaging.channels::AMFChannel)#4
eventPhase = 2
faultCode = "Channel.Connect.Failed"
faultDetail = "NetConnection.Call.Failed: HTTP: Failed: url: 'http://ainApp.swf/messagebroker/amfpolling'"
faultString = "error"
reconnecting = false
rejected = false
rootCause = (Object)#8
code = "NetConnection.Call.Failed"
description = "HTTP: Failed"
details = "http://ainApp.swf/messagebroker/amfpolling"
level = "error"
target = (mx.messaging.channels::AMFChannel)#4
type = "channelFault"
timestamp = 0
timeToLive = 0
This is my desktop application that I'm trying to send messages from:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.messaging.events.ChannelEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.messages.AsyncMessage;
protected function cons_faultHandler(event:MessageFaultEvent):void
{
trace(event.message + ' fault')
}
]]>
</fx:Script>
<fx:Declarations>
<s:Consumer id="cons" destination="cricket" message="messages.text += event.message.body.msg + '\n'" fault="cons_faultHandler(event)"/>
<s:Producer id="prod" destination="cricket" fault="cons_faultHandler(event)" />
</fx:Declarations>
<s:VGroup verticalScrollPosition="0" horizontalScrollPosition="0">
<s:TextArea id="messages" width="100%" height="50%"/>
<s:TextInput id="mesgSender" />
<s:Button id="send" label="send" click="prod.send(new AsyncMessage({msg:mesgSender.text+'asdasd'}))"/>
</s:VGroup>
</s:WindowedApplication>
And this are my messaging-config.xml and services-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
</services>
<security>
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
</security>
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Error">
<properties>
<prefix>[BlazeDS] </prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint.*</pattern>
<pattern>Service.*</pattern>
<pattern>Configuration</pattern>
</filters>
</target>
</logging>
<system>
<redeploy>
<enabled>false</enabled>
</redeploy>
</system>
</services-config>
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"
class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
<!-- <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/> -->
</adapters>
<default-channels>
<channel ref="my-polling-amf"/>
</default-channels>
<destination id="cricket">
<channel ref="my-amf"/>
</destination>
</service>
I don't know what I'm doing wrong and why in error message, the endpoint url is "http://ainApp.swf/messagebroker/amfpolling". My desktop apps name is MainApp by the way.
Thanks
回答1:
In services-config.xml you should define your channel url.
url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
to like this
url="/yourContextRootName/messagebroker/amf"
Do not define server.name and server.port, it comes with similar problem.
来源:https://stackoverflow.com/questions/13953123/blazeds-messaging-channel-connect-failed-error