3 Replies Latest reply: Dec 20, 2011 6:15 AM by Rohit . Kumar RSS

    Session Timeout when using StreamingAMFChannel

    ildaronline

      Hi. When using a StreamingAMFChannel the clients http session expires dropping the connection. I use programmatically created multiple mx:Consumer instances. Session expirations occur after 900 seconds from consumer subscription. How can i solve it?

        • 1. Re: Session Timeout when using StreamingAMFChannel
          Rohit . Kumar Adobe Employee

          Can you paste your services-config.xml as well as your client side code for setting up the consumer?

           

          Rohit

          • 2. Re: Session Timeout when using StreamingAMFChannel
            ildaronline

            Hi, Rohit,

             

            my services-config.xml

             

            <?xml version="1.0" encoding="UTF-8"?>

            <services-config>

            <!---->

            <!--    <factories>-->

            <!--        <factory id="SpringFactory" class="com.adobe.factories.MyFactory" /> -->

            <!--    </factories> -->

             

            <!--    <factories>-->

            <!--        <factory id="spring" class="blazeds.spring.factory.SpringFactory"/>-->

            <!--    </factories>-->

             

                <services>

                    <service-include file-path="remoting-config.xml" />

                    <service-include file-path="proxy-config.xml" />

                    <service-include file-path="messaging-config.xml" />                               

             

                    <default-channels>

                       <channel ref="my-amf"/>

                       <!-- <channel ref="my-streaming-amf"/>-->

                    </default-channels>

             

                </services>

             

             

                <security>

                    <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>

                    <!-- Uncomment the correct app server

                    <login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss">

                    <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>       

                    <login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/>

                    <login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/>

                    -->

             

                    <!--

                    <security-constraint id="basic-read-access">

                        <auth-method>Basic</auth-method>

                        <roles>

                            <role>guests</role>

                            <role>accountants</role>

                            <role>employees</role>

                            <role>managers</role>

                        </roles>

                    </security-constraint>

                     -->

                </security>

             

                <channels>

             

                    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">

                        <endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>

                    </channel-definition>

             

                    <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">

                        <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>

                        <properties>

                            <add-no-cache-headers>false</add-no-cache-headers>

                        </properties>

                    </channel-definition>

             

                    <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">

                        <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>

                        <properties>

                            <polling-enabled>true</polling-enabled>

                            <polling-interval-seconds>4</polling-interval-seconds>

                        </properties>

                    </channel-definition>

             

                    <channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">

                          <endpoint url="http://{server.name}:{server.port}/{context.root}/spring/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint" />

                         <properties>

                              <idle-timeout-minutes>0</idle-timeout-minutes>

                              <max-streaming-clients>10</max-streaming-clients>

                              <server-to-client-heartbeat-millis>5000</server-to-client-heartbeat-millis>

                             <user-agent-settings>

                                  <user-agent match-on="MSIE" kickstart-bytes="2048" max-streaming-connections-per-session="3" />

                                  <user-agent match-on="Firefox" kickstart-bytes="2048" max-streaming-connections-per-session="3" />

                              </user-agent-settings>

                        </properties>

                      </channel-definition>

             

                    <!--

                    <channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel">

                        <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/>

                    </channel-definition>

             

                    <channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">

                        <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>

                        <properties>

                            <add-no-cache-headers>false</add-no-cache-headers>

                        </properties>

                    </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>

                            <pattern>Message.General</pattern>               

                        </filters>

                    </target>

                </logging>

             

                <system>

                    <redeploy>

                        <enabled>false</enabled>

                        <!--

                        <watch-interval>20</watch-interval>

                        <watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file>

                        <watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file>

                        <watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-file>

                        <watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-file>

                        <watch-file>{context.root}/WEB-INF/flex/data-management-config.xml</watch-file>

                        <touch-file>{context.root}/WEB-INF/web.xml</touch-file>

                         -->

                    </redeploy>

                </system>

             

            </services-config>

             

            Client code in .as

             

            var consumer:Consumer;

            consumer = new Consumer();

            consumer.destination = destination;

            consumer.addEventListener(MessageEvent.MESSAGE, onMsg);

            consumer.addEventListener(MessageAckEvent.ACKNOWLEDGE, acknowledgeHandler);

            consumer.addEventListener(MessageFaultEvent.FAULT, messageFaultHandler);

            consumer.channelSet = streamingChannelSet;

             

            mxml

             

            <mx:ChannelSet id="streamingChannelSet">  

            <mx:StreamingAMFChannel url="{parentApplication.endPointRoot + '/spring/messagebroker/streamingamf'}"/>

            </mx:ChannelSet>

             

            Also i create destinations in java this way:

             

            MessageDestination destination = (MessageDestination)service

                                .createDestination(destinationName);

            destination.setSource(destinationName);   

            ConfigMap accessConfig = new ConfigMap();

            accessConfig.addProperty("use-mappings", "true");

            accessConfig.addProperty("method-access-level", "remote");

            ConfigMap serviceAdapterConfig = new ConfigMap();

            serviceAdapterConfig.addProperty("access", accessConfig);               

            destination.addChannel("my-streaming-amf");           

            destination.addChannel("my-polling-amf");

            destination.addChannel("my-amf");

            destination.getServerSettings().setDurable(true);

            destination.setAdapter(

               new PublisherServiceAdapter(wellId, paramName)               

            );

            destination.start();

             

            private class PublisherServiceAdapter extends ServiceAdapter {

             

                    private String wellId;

             

                    private String paramName;

             

                    public PublisherServiceAdapter(String wellId, String paramName) {           

                        super();

                        this.setId(UUIDUtils.createUUID());

                        this.wellId = wellId;

                        this.paramName = paramName;

                    }

             

                    @Override

                    public Object invoke(Message message) {

                        MessageService msgService = (MessageService)getDestination().getService();

                        msgService.pushMessageToClients(message, true);

                        msgService.sendPushMessageFromPeer(message, true);

                        return null;

                    }

             

                    @Override

                    public boolean handlesSubscriptions()

                    {

                        return true;

                    }

             

             

                    @Override

                    @SuppressWarnings("unchecked")

                    public Object manage(CommandMessage commandMessage){

                        if (commandMessage.getOperation() == CommandMessage.SUBSCRIBE_OPERATION) {

                            AcknowledgeMessage ackMessage = new AcknowledgeMessage();

                            Map<String, Object> paramData;// = wellOperdata.get(paramName);           

                            if(wellsOperData.get(wellId) != null &&

                                    (paramData = (Map<String, Object>)wellsOperData.get(wellId).get(paramName)) != null){

                                Map<String, Object> sendData = new HashMap<String, Object>();

                                sendData.putAll(paramData);

                                sendData.put("wellId", wellId);

                                sendData.put("paramName", paramName);

                                ackMessage.setBody(sendData);

                            }                           

                            return ackMessage;

                        }

                        else

                            return null;

                    }

             

                }

            • 3. Re: Session Timeout when using StreamingAMFChannel
              Rohit . Kumar Adobe Employee

              Consider setting heartbeatinterval on the channelset in order to keep the session alive.

               

              Rohit