BlazeDS 消息传递 Channel.Connect.Failed 错误 [英] BlazeDS Messaging Channel.Connect.Failed Error

查看:17
本文介绍了BlazeDS 消息传递 Channel.Connect.Failed 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上搜索过,对此错误的任何答案都无法解决我的问题.

I searched through the internet and any answer for this error could not solved my problem.

我在 Openshift 中有一个 blazeds 服务器,我通过 Flash Builder 连接到它.我想做一个应用程序,它将向所有使用我的应用程序的其他用户发送消息.

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.

我的意思是我有 2 个应用程序.一个将向服务器发送消息,这个将在桌面上,另一个是移动项目,将接收我通过服务器从桌面应用程序发送的消息.

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.

我尝试使用 BlazeDS 消息传递,但出现此错误:

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>

这是我的 messages-config.xml 和 services-config.xml:

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>

我不知道我做错了什么以及为什么在错误消息中,端点 url 是http://ainApp.swf/messagebroker/amfpolling".顺便说一下,我的桌面应用名称是 MainApp.

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.

谢谢

推荐答案

在 services-config.xml 中,您应该定义您的频道 url.

In services-config.xml you should define your channel url.

url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"

喜欢这个

url="/yourContextRootName/messagebroker/amf"

不要定义 server.name 和 server.port,它有类似的问题.

Do not define server.name and server.port, it comes with similar problem.

这篇关于BlazeDS 消息传递 Channel.Connect.Failed 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆