<div dir="ltr">Hi,<br><br>I am sorry for emailing my question a few times.&nbsp; I need to get Flex to successful establish connection with RabbitMQ inside my Flex application in order to position the use of RabbitMQ in our application.&nbsp; I can establish a AMPQ to AMPQ connection using Java client for both publisher and subscriber, but I am not able to use Flex as the subscriber.&nbsp; I know I may try using FM3 to act as the subscriber, but I still think the best and most straight forward solution is to have Flex client to subscribe directly to RabbitMQ.&nbsp; <br>
<br>RabbitMQ.log says:
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><b>error on TCP connection &lt;0.8716.0&gt; from <a href="http://192.168.1.100:50021/" target="_blank">192.168.1.100:50021</a></b></div>
<div><b>{handshake_timeout,frame_</b><b>header}</b></div><br><br>Here is my code, could someone help me to find out what is wrong?&nbsp; <br><br><br><div>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;mx:Application xmlns:mx=&quot;<a href="http://www.adobe.com/2006/mxml" target="_blank">http://www.adobe.com/2006/mxml</a>&quot; <br>
&nbsp;&nbsp;&nbsp; layout=&quot;absolute&quot; styleName=&quot;plain&quot;&nbsp; creationComplete=&quot;init()&quot;&gt;</div>

<div>&nbsp; &lt;mx:Script&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;![CDATA[<br>&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.patterns.impl.SubscribeClientImpl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import org.amqp.patterns.SubscribeClient;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.Connection;<br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.ConnectionState;<br>

&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.patterns.CorrelatedMessageEvent;<br>&nbsp;&nbsp;import org.amqp.ProtocolEvent;<br>&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.Session;<br>&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.SessionManager;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;import org.amqp.impl.SessionStateHandler;</div>


<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private var subClient:SubscribeClientImpl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected var connection:Connection;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;private var serializer:JSONSerializer = new JSONSerializer();</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public function init():void {<br>&nbsp;&nbsp;&nbsp;trace(&quot;test sub init&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection = new Connection(buildConnectionState());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subClient = new SubscribeClientImpl(connection);<br><b>&nbsp;&nbsp;&nbsp;subClient.serializer = serializer;<br>

//&nbsp;&nbsp;&nbsp;subClient.realm = &quot;/data&quot;;<br>&nbsp;&nbsp;&nbsp;subClient.exchange = &quot;gamex&quot;;<br>&nbsp;&nbsp;&nbsp;subClient.exchangeType = &quot;topic&quot;;<br>&nbsp;&nbsp; sub.subscribe(&quot;SimpleQueue&quot;,onMessageArrive);</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp; &nbsp;&nbsp;public function buildConnectionState():ConnectionState {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var state:ConnectionState = new ConnectionState();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state.username = &quot;guest&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state.password = &quot;guest&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state.vhostpath = &quot;/&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state.serverhost = &quot;<a href="http://192.168.1.104/" target="_blank">192.168.1.104</a>&quot;;<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return state;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;public function onMessageArrive(event:CorrelatedMessageEvent):void {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var o:* = event.result;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; ]]&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/mx:Script&gt;</div>


&lt;/mx:Application&gt;<br></div>