1 Reply Latest reply on Oct 6, 2011 6:34 PM by Alex Glosband

    Changing socket server config at runtime

    ChristopherWhite

      Is it possible to modify properties of a socket server at runtime without needing to change the xml? For example, if I wanted to change something like connection-idle-timeout-minutes from 120 to 60, could I do it without modifying the following xml block in services-config.xml and redeploying?

       

           <server id="my-nio-server" class="flex.messaging.socketserver.SocketServer">

                  <properties>

                      <connection-idle-timeout-minutes>120</connection-idle-timeout-minutes>

                      <socket-keep-alive-enabled>true</socket-keep-alive-enabled>

                      <max-worker-threads>200</max-worker-threads>

                      <min-worker-threads>200</min-worker-threads>

                      <accept-thread-priority>7</accept-thread-priority>

                      <accept-backlog>25</accept-backlog>               

                  </properties>

              </server>

       

      I ask because our application is large enough that off cycle deploys or downtimes are rarely feasible, and it would be convenient if there were a way to change these values at runtime.

        • 1. Re: Changing socket server config at runtime
          Alex Glosband Adobe Employee

          It looks like it might be possible although none of the APIs you need to do it are published.

           

          I can tell you what the APIs are if you want to give it a try and see if it works for you.

           

          The flex.messaging.socketserver.SocketServer class has a setConnectionIdleTimeoutSeconds(int value) method that you can call to change the connection idle timeout. It looks like this is thread safe so you should just need to get the SocketServer at runtime and call the method.

           

          NIO endpoints that extend from flex.messaging.endpoints.BaseSocketServerEndpoint have a getSocketServer() method you can use to get the SocketServer.

           

          You can get an NIO endpoint from the MessageBroker by calling getEndpoint(String) and passing in the endpoint id or getEndpoints() to get a Map of all the endpoints.

           

          So, to sum up, you should be able to first get the MessageBroker. For example, in a servlet you can call FlexContext.getmessageBroker() to get it. Next, you would get the endpoint from the MessageBroker and then get the SocketServer from the endpoint. Once you have the SocketServer, you should be able to call setConnectionIdleTimeoutSeconds to change the connection idle timeout.

           

          Hope that helps.

           

          -Alex