4 Replies Latest reply on Apr 6, 2015 4:28 PM by Paul Ferraro

    limit number of http sessions

    Mark Lybarger Apprentice

      i'd like to limit the number of http sessions in my application.  i thought i could set the following in jboss-web.xml

       

      <jboss-web>   
         <max-active-sessions>1</max-active-sessions>
         <passivation-config>
            <use-session-passivation>false</use-session-passivation>
         </passivation-config>
      </jboss-web>
      

       

      to limit to one http session, but then i hit the app with two instances and both get a session created. 

       

      i used a simple jsp to create the session:

      <html>
      <body>
      <h2>Hello World!</h2>
      <%=request.getSession().toString()%>
      </body>
      </html>
      

       

      and i use jboss cli to verify the session count:

      [standalone@localhost:9990 /] /deployment=example.war/subsystem=undertow/:read-resource(include-runtime=
      true)
      {
          "outcome" => "success",
          "result" => {
              "active-sessions" => 2,
              "context-root" => "/example",
              "server" => "default-server",
              "sessions-created" => 2,
              "virtual-host" => "default-host",
              "servlet" => undefined
          }
      }
      

       

      any ideas or help would be appreciated.  currently, i have an application that has manual session tracking and counting. that code seems volatile to me.  the servlet has a static variable that gets incremented when sessions are created and decremented when sessions are destroyed.  when they're over the max, the servlet handles the response. 

       

      thanks!

      -mark-