Sockets - maintain session

DOes any one know of a good way to maintain a user session over a socket. Here is my scenario:
I have a rich client (swing) that presents users with a login dialog. The login information is then sent over a socket to a server that then sends back some Session object or unique id that is passed to the server each time data is needed. For instance :
socket_conn_wrapper.someMethodCall(sessionId, arg2,arg3);
OR
String session_id = socket_conn_wrapper.login("user","pass");
socket_conn_wrapper.setSessionId(session_id);
socket_conn_wrapper.someMethodCall(arg2,arg3); // subsequent calls will send session id
Is this good practice?

Looks perfectly reasonable. You might want to consider
a few things. (Maybe you already have.)
o Specifics: Generally not a good practive to transmit
passwords, so you may want to dream up some other kind
of handshake.For password protection during transmission i figure that i would utilize that packages that java provides for secure sockets.
o Need a way to deal with a client that dies, leaving
a session open.
This would be done by some sessiion cleaner (Session Manager) that runs withing the server as a daemon. THe session manager might keep session id s in some ccollection that it iterates once in a blue moon and figures out if the client socket associated with the session is is still alive. If not then it gets trashed.

Similar Messages

  • Sun Ray Connector proxy : Child closed socket prematurely, session shutdown

    Dear All,
    I'm using SRS 5 & SRWC 2.2 :
    $ pkginfo -l SUNWuttsc
       PKGINST:  SUNWuttsc
          NAME:  Sun Ray Connector for Microsoft Windows Operating Systems (opt)
      CATEGORY:  system,sunray
          ARCH:  i386
       VERSION:  2.2_32
       BASEDIR:  /opt
        VENDOR:  Sun Microsystems, Inc.
          DESC:  Commands, configuration, resources and Man Pages
        PSTAMP:  SunOS_5.10_20091021175007
      INSTDATE:  févr 05 2010 10:34
       HOTLINE:  Please contact your local service provider
        STATUS:  Installation complète.
         FILES:       26 chemins d'accès installés
                       9 répertoires
                      10 exécutables
                       1 exécutables setuid/setgid
                    9037 blocs utilisés (env.)
    The SRWC crash and restart immediately...
    As you can see I've some log like this :
    Feb  7 03:03:15 SRS Sun Ray Connector proxy:[18056]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:15 SRS Sun Ray Connector proxy:[18089]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18254]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18214]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18219]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18221]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    Feb  7 03:03:23 SRS Sun Ray Connector proxy:[18220]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    ...I'm using a separate DHCP on LAN. DTU & TSE (W2K8) are working 95% of time and sometime and randomly, one DTU has a full black screen. The only way to get the login screen of win 2K8 is to reset his own session.
    Help will be really appreciated.
    Florent.

    I have the same issue . . .
    1. Sun Ray 5 (Sun Ray 4.2)
    2. SRWC 2.2
    3. Solaris 10 u9 X86 on two x2200
    4. Terminal Server on Win2K3 R2 Standard x64 Edition SP2
    I have a handful of users and they all logon the same way, which is to enter username & password then I have the following lines at the end of the users' individual .dtprofile file . . .
    <begin snip>
    DTSOURCEPROFILE=true
    /opt/SUNWuttsc/bin/uttsc -b -m -O -u uname 192.168.100.29
    exit
    <end snip>
    Of course 'uname' is actually the user name followed by the Terminal Server IP address and as you can see I am using the '-O' option, but every morning all the users on a server have their Sun Ray sessions reset and I find this in the messages file . . .
    Mar 16 09:38:31 sunraya Sun Ray Connector proxy:[12941]: [ID 855542 user.error] Child closed socket prematurely, session shutdown
    . . . . Using cron, I reset the Sun Ray service twice a day on both servers at 7AM and 7PM . . .
    # cat /sunray-restart.script
    # This is to restart SunRay 5 service due to
    # what I think may be a memory leak that disconnects
    # the SunRay Windows Connector every day
    /opt/SUNWut/sbin/utrestart -c
    echo "#" >> /var/adm/messages
    date >> /var/adm/messages
    echo "#" >> /var/adm/messages
    echo " RESTARTING SUNRAY SERVICE " >> /var/adm/messages
    echo "#" >> /var/adm/messages
    echo "#" >> /var/adm/messages
    . . . But this does not appear to having an affect.
    I will be looking around the forums for any other bits of information about this. The "Known Issues" can probably be found in the Release Notes.

  • Maintaining Session State

    Hello,
    Does anyone know how to maintain session and application variables through server restarts? I want to be able to shutdown and startup my Tomcat server without having the users lose their session and application variables (and consequently, their data and login state).
    Any ideas?
    Thanks!
    -David

    I dont think its possbile since stopping and restarting gets new sessions. Only way that I would know would be to use cookies.
    But then again i dont like the idea of saving passwords in cookies

  • Maintain session in JSP frame

    Hi,
    I am having trouble in maintaining session in jsp frames. -
    Here is sample code
    parent.jsp
    <HTML>
    <HEAD>
    <LINK rel=stylesheet type="text/css" href="defaults.css">
    <TITLE>abc</TITLE>
    <%     
         String checkAmount = "100.00";
         session.setAttribute("checkAmount", checkAmount);
         System.out.println("checkAmount in ppmain"+session.getAttribute("checkAmount"));
    %>
    <FRAMESET rows="235,*" frameborder="no" >     
    <FRAME NAME="pptop" SRC="top.jsp" frameborder=0 scrolling=no noresize >
    <FRAME NAME="ppbottom" SRC="bottom.jsp" frameborder=0 scrolling=no marginwidth=0 marginheight=0 noresize>
    </FRAMESET>
    </HTML>
    top.jsp -
    <HTML>
    <HEAD>
    <LINK rel=stylesheet type="text/css" href="defaults.css">
    <TITLE>top</TITLE>
    <%     
    System.out.println("session in top "+session);
    System.out.println("checkAmount in top "+session.getAttribute("checkAmount"));
    %>
    </HTML>
    It is not able to retain session in the top.jsp ( in SOP for session I get different session ID in parent.jsp and top.jsp
    This Works well in local but when gets deployed to WAS6 server troubles starts.
    Any help is appreciated.
    Thanks

    When you create URLs, you might want to try using JSTL to rewrite them:
    <FRAME NAME="pptop"
           SRC="<c:url value='top.jsp'/>"
           frameborder=0
           scrolling=no
           noresize >
    <FRAME NAME="ppbottom"
           SRC="<c:url value='bottom.jsp'/>"
           frameborder=0
           scrolling=no
           marginwidth=0
           marginheight=0
           noresize>Or you can use:
    SRC='<%= response.encodeURL("top.jsp") %>'

  • Regarding maintaining session in flex

    Hello,
              I am developing a flex application which is using jsp for database connectivity. I am using HTTP request for connecting to jsp page and passing and retrieving parameters. Now I wanted to ask how can I maintain session in flex so that I can know which client has logged into the system and on the basis of that can assign privileges to the client. Is it possible in flex and how?Reply needed urgently.
    Thanks in advance.

    Hi a.bhavika,
    There is not specifically any session management in Flex as it runs everything on the client side if at all you want to mainatain you can maintain it on the server side. ...and I think for your case I dont think you need any session managemenet as at the time of login only you can identify which user has logged in to the syetem and based on the user logged in you can load all the previleges of that particular user in the Flex application.
    Check out the links below for your understanding...
    http://www.forta.com/blog/index.cfm/2006/9/24/flex-and-session-state-management
    http://www.assembla.com/wiki/show/romoz/Session_Management_in_Flex
    Thanks,
    Bhasker

  • Maintain session in Multiple soap calls

    Hi Experts,
    We have an requirement which runs 2 synchronous calls.
    1st synchronous cal is for validating user credentials and
    2nd synchronous call (for successful log in) for uploading data in R/3 system.
    The main task is to maintain session(ex: time 15 mins) .
    1st synchronous call looks like Mobile Application (soap sender)<--->PI<----->(Soap receiver)Active Directory.
    2nd synchronous call looks like Mobile Application (Soap sender)<--->PI<----->(Proxy)R/3 system.
    can you pls let me know how can I achieve this requirement and
    how to maintain session ID, session (is it in PI or in third party) and from where to maintain session.
    Thanks in Adv..

    I am calling multiple web service apis from my bpel process on the same link. The Web services are written such that I always have to call a "login" api first which creates a context that's maintained throughout the session. Thus subsequent ws calls have to be made in the same session because all the other web service apis require the context to be present.
    You can think of this as a stateful SessionBean (sort of).
    The question is does bpel support this?

  • Maintaining Sessions through Multiple Servlets and Contexts

    Hi,
    I have a webapplication that works like this:
    * User connects to a login servlet on HTTPS
    * Users information is authenticated on HTTPS
    * An object is stored in the session for other servlets to validate the users access
    * Authenticated users are forwarded to an HTTP page where the session is used to make sure they were granted access
    My problem is this....Since I create the session in an HTTPS context, when I am in the HTTP context, I am unable to access the session and constantly get NULL. Is there any way that I can access the session from an HTTP context?

    What you can do is, just login using HTTPS and switch over to HTTP
    and then store data in session.That is true, but what I want in the session is basically a flag on whether or not the user was granted access. I would much rather set all that up on the secure line, and then just access it from the unsecure ones...
    For example, you are creating session using the
    http://testdev:port/index.jsp page.
    If access the same page(with hostname)
    http://10.300.20.18:8080/index.jsp, you can't get the session even
    though both are same web server and same web application. Because the
    browser treats it different sessionI think if you use my above solution with the explicit passing of the jsessionid, you can move from one domain to another and still maintain session. Not positive on that though...

  • Maintaining session in portal

    Hi,
    I want to maintain session expire time in portal for my iViews both Porta components and Web Dynpro. Where can I set this value.
    Please let me know
    Thanks
    Bobby M

    Hi,
       I'm sorry. Messed it up Go through Web Dynpro application needs to never expire..
    Regards,
    Satyajit.
    Message was edited by:
            Satyajit Chakraborty

  • Maintain session

    I have a client side java program running. It is to comunicate with a web server using HTTP. How do I maintain session in my java program in the client machine. I have no access to the web server.
    java.net.URL and java.net.HttpURLConnection are not maintaining session, tough allow me to transact. It creates a new session for every hit.
    help!!!
    Trijoy
    [email protected]

    Hello Darted,
    I have a small task ahead. My boss hates logging in userid and passwords every time he logs ont a site, which he dose 10-15 times a day. Due to session timeouts, he has to repeat the login process.
    The requirement is that, I should have a process running, that will maintain the session throughout the day by hitting the URL every 18 mins or so..(session timeout is of 20 mins), and when he writes the URL the old session is maintained.
    The process is such that it sends data over http to the server. The data is accepted only for the live and valid session. At present we are sending it through a form (post). If the state can be maintained in the java applet, swing or whatever, we will remove the HTML form and will automate the process of form sending.
    I am looking for a mechanism which emulates a browser, i.e. maintain the session till it gets time out or browser is closed.... only I want to avoid using a browser and refreshing it every time and want to implement it thru java so that I can have control over it.
    Thanks
    Trijoy
    PS. Any help in design, source code, suggestion is highly appreciated

  • Cisco ace Load balancer not maintaining session persistence

    Hi All,
    We have observed from the IIS logs on the internal webservers that loadbalancer is not maintaining session persistence for two specific request for the internal servers.
    https://123.xyz.com/Webresource.axd
    https://123.xyz.com/ScriptResource.axd
    Error
    Webresource.axd : 500
    Scriptresource.axd: 404
    Session persistence is maintained for all other requests hitting loadbalancer.
    Issue is observerd on hits for these two specified components. WebResource.axd and ScriptResource.axd are Http Handlers used by ASP.NET and Ajax to add client-side scripting to the outgoing web page.
    For e.g /WebResource.axd d=t2GXfySdqWmJ-lZSI0KVbw2&t=634868473645172160 is valid for server 1 and return 200 response but the same request is seen on few other servers where the response is 404 even though load balancer cookie is same. This means that if the request for the both the axd contains a valid decrypter and it connects to the right server then the response seen is 200.
    The url passed by the user contains d and t parameters when are unique for each user session.
    Solution tried:
    Accessed website via another VIP without http redirect rule but could not see difference.
    Tried to match machine key across all servers : Failed . Could see the ‘d’ value different for each server.
    Load balancer VIP :
    x.x.x.x
    redirect: http > https
    SSL Offload : ON
    Poool:
    WEB1
    WEB2
    WEB3
    WEB4
    WEB5
    All servers listening on port 80
    sticky config:
    sticky ihttp-cookie cookie1 vip-1.1.1.1-80-stickyfarm
      cookie insert browser-expire
      replicate sticky
      serverfarm vip-1.1.1.1_80
    sticky http-cookie cookie1 vip-farm:1.1.1.1:443
      cookie insert browser-expire
      replicate sticky
      serverfarm farm:1.1.1.1:443
    Has anyone else come across similar issue?
    Can you plese check if there is any config on cisco ace that will ensure that session persistence is maintained for these 2 requests.
    Thank you for all the help.
    regards,
    Sangram

    Hello Sangram,
    We would need simultanous packet traces before and after the ACE to get to the root cause of this issue so I would recommend that you open a cisco tac case for more in depth troubleshooing of this issue.
    Joel Lamousnery
    CCIE R&S - 36768
    Engineer, Customer Support
    Technical Services

  • Maintaining session info on the CSS

    I know by default the CSS cannot do this but what if I want it to. I have an IM application that a person has requested be put behind the CSS. They want it to be able to maintain sessions during a failover event. Any way to do this with the CSS?

    You could talk to your Cisco office and see if they would consider it for a future release. If there’s enough demand, you may get it through. What messaging software are you using?

  • How to maintain Session between two ear files?

    HI Guys
    I have deployed two ear files in oc4j. One is used to open applet and other for business operations.
    My problem is after calling applet my session gets invalidate. How to save session between two context
    I am new in this field please help!!
    the sooner the better
    Rahul

    Can I do this if I integrate oc4j with apache!!
    Can I maintain session
    Plz. Help
    Rahul

  • Jaxm - Maintaining Session State

    Hi,
    I have the following problem:
    My client dispatches jaxm-soap-messages to a java-servlet using the reference implementation of sun (wsdp). For each time I use the same SOAP-connection object. The problem is, that the servlet opens with each inquiry a new session. How can I maintain the session ( for example setting a cookie in case of http as the protocoll)? Is there a mapping between parameter in soap-header to http-header ?
    Greetings,
    Zubow

    Hi. I ran into the same situation a while back. I'll tell you how
    I resolved the problem.
    You have to build your own handler class. Extend the javax.xml.rpc.handler.GenericHandler class. Implementing the handleRequest(MessageContext msg) method.
    1 public boolean handleRequest(MessageContext context)
    2 {
    3 try
    4 {
    5 SOAPMessageContext smc = (SOAPMessageContext)context;
    6 SOAPMessage message = smc.getMessage();
    7 MimeHeaders mimeHeaders = message.getMimeHeaders();
    8 if(mimeHeaders.getHeader("Cookie")==null && getCookie()!=null)
    9 {
    10 mimeHeaders.setHeader("Cookie",getCookie());
    11 }
    12 }
    13 catch(Exception e)
    14 {
    15 throw new JAXRPCException(e);
    16 }
    17 return true;
    18 }
    19 public boolean handleResponse(MessageContext context)
    20 {
    21 try
    22 {
    23 SOAPMessageContext smc = (SOAPMessageContext)context;
    24 SOAPMessage message = smc.getMessage();
    25 MimeHeaders mimeHeaders = message.getMimeHeaders();
    26 if(mimeHeaders.getHeader("Set-Cookie")!=null && getCookie()==null)
    27 {
    28 String[] headerValues = mimeHeaders.getHeader("Set-Cookie");
    29 String cookie = headerValues[0];
    30 if(cookie.indexOf(";") >= 0)
    31 {
    32 cookie = cookie.substring(0,cookie.indexOf(";"));
    33 }
    34 setCookie(cookie);
    35 }
    36 }
    37 catch(Exception e)
    38 {
    39 throw new JAXRPCException(e);
    40 }
    41 return true;
    42 }
    The overall concept is to handle the soap message before it goes back
    to the server. You need to add the COOKIE header variable set to JSESSIONID=your session id
    to the message header before every request goes to the server. The handleResponse looks for set-Cookie variable that comes back from the
    very first request.
    Hope that helps.
    Mike
    first request.

  • Problems with maintaining session state using mod_ose

    I am using 9i AS(version 1.0.2.0) and oracle 8i(version 815).
    Because i need to maintain client sessions for my application, I
    have activated mod_ose(for stateful session). As suggested in
    the oracle documentation, i created a package containing
    variables for which state needs to be maintain per client. The
    state is maintained by the app server but it is not maintained
    properly. All the new clients that connect to the app server
    share the same session variable values. If I change a package
    variable value from one client, other clients take the same
    value.
    Any solution?
    Suggestions are most welcome.
    Thanks in advance.

    We installed oracle9i AS on solaris, configured OSE and the
    problem is not occuring now. Not sure whether its solaris that
    worked or 9i AS had some problem on NT machine earlier.
    Regards,
    Sharad

  • Maintain session in JSP after using filters

    I have to extend this application to maintain the session , because there are 10 jsp pages in my application.
    When the user logs in , and hits a tab(which should redirect to another jsp page - assume users.jsp) the page is redirected back to the login page (instead of the users.jsp page) because of the filter.
    How do I maintain the session here , so that a user who is logged in (with user name and password) could access the other pages instead of just being redirected back to the login.jsp page.
    this is my filter page
    package com.bea.genesis.tenantmgmt.utils;
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class FacesRedirectFilter implements Filter {
         public void doFilter(ServletRequest req,ServletResponse res,FilterChain chain)
         throws ServletException, IOException
              HttpServletRequest request = (HttpServletRequest)req;
              HttpServletResponse response = (HttpServletResponse)res;
              //String uri = request.getRequestURI();
              String relativePath = request.getServletPath();
              if ((relativePath.indexOf("/pages/") >= 0) && relativePath.endsWith(".jsf")) {
                   //int length = uri.length();
                   //String newAddress = uri.substring(0, length-3) + EXTENSION;
                   //response.sendRedirect("login.jsf");
                   RequestDispatcher rd = request.getRequestDispatcher("login.jsf");
                   rd.forward(req, res);
              chain.doFilter(request, response);
         public void destroy() {
              // TODO Auto-generated method stub
         public void init(FilterConfig filterConfig) throws ServletException {
              // TODO Auto-generated method stub
    Please reply
    thanks

    Thanks for the reply , How do I test in the filter whether the user is loged in or not.(I dont have clue , how to do tht)
    this is my login Bean ---
    import java.util.Map;
    import javax.faces.context.FacesContext;
    public class LoginBean extends AbstractBean {
         private String loginId;
         private String password;
         private LoginService loginService;
         private LoginValidator loginValidator = new LoginValidator();
         private TenantProfileService tenantProfileService;
         public String getLoginId() {
              return loginId;
         public void setLoginId(String _loginId) {
              loginId = _loginId;
         public String getPassword() {
              return password;
         public void setPassword(String _password) {
              password = _password;
         public LoginService getLoginService() {
              return loginService;
         public void setLoginService(LoginService loginService) {
              this.loginService = loginService;
         *public String login() {*
    *          String authenticationStatus = GenesisConstants.RESULT_FAIL;*
    *          appLogger.enterMethod(this, "login", loginId);*
    *          if (loginValidator.validateData(this)) {*
    *               try {*
    *                    long profileId = loginService.authenticateUser(loginId,*
    *                              password);*
    *                    TenantProfileData tenantProfileData = retrieveTenantProfile(profileId);*
    *                    if (tenantProfileData == null || !tenantProfileData.getStatus().equalsIgnoreCase(*
    *                              GenesisConstants.TENANT_STATUS_ACTIVE))*
    *                         throw new LoginException(*
    *                                   "Tenant profile Not Active for the user.");*
    *                    authenticationStatus = GenesisConstants.RESULT_SUCCESS;*
    *               } catch (LoginException le) {*
    *                    appLogger.error("Error in User Authentication", le.getMessage());*
    loginValidator.addErrorMessage(null, le.getMessage());
    *                    authenticationStatus = GenesisConstants.RESULT_FAIL;*
              appLogger.exitMethod(this, "login", loginId);
              return authenticationStatus;
         public TenantProfileData retrieveTenantProfile(long profileId) {
              appLogger.enterMethod(this, "viewTenant");
              FacesContext facesContext = FacesContext.getCurrentInstance();
              Map<String, Object> sessionMap = facesContext.getExternalContext()
                        .getSessionMap();
              appLogger.debug("profileId==", profileId + "");
              TenantProfileData tenantProfileData = new TenantProfileData();
              try {
                   appLogger.debug("invoking TenantProfileService.getTenantById");
                   tenantProfileData = tenantProfileService.getTenantById(profileId);
                   appLogger
                             .debug("successfully completed TenantProfileService.getTenantById");
              } catch (TenantProfileServiceException te) {
                   appLogger.debug("exception in TenantProfileService.getTenantById");
                   throw new DataException(te.getMessage());
              sessionMap.put("tenantProfileData", tenantProfileData);          
              appLogger.exitMethod(this, "viewTenant");
              return tenantProfileData;
         public TenantProfileService getTenantProfileService() {
              return tenantProfileService;
         public void setTenantProfileService(
                   TenantProfileService tenantProfileService) {
              this.tenantProfileService = tenantProfileService;
    PLEASE HELP
    THANKS

Maybe you are looking for

  • How to stop jobs after a system copy

    Hi All, After doing a system copy from the Production system to some test system, all the jobs that are supposed to be triggered in the production server will also trigger in the test system which is not good. For example, If we have a payroll runnin

  • FLV files won't play on testing server

    I've created a site with several videos on multiple pages. They play on my local computer but will not work when uploaded to my server. I get an error in opening the page and a "plug-in cancelled" message in the Activity window in Safari. Other FLV f

  • ALV: multiselect selects more rows than expected

    If I have table with many pages of data and do following actions: 1) leave lead select in first page as it is 2) go to next page - with ctrl select 2nd row 3) go to next page - with ctrl select 1st row 4) go back to previous page - 2nd row selected a

  • How to create Groups in UME instead of LDAP(AD) when use writeable AD

    Hi experts, Our portal user UME are now connected to AD LDAP with dataSourceConfiguration_ads_writeable_db.xml (enabled SSL).  So when creating user and groups in portal, it is created in AD, but if I want create groups in UME, how it can be done? An

  • Socket latency

    I am experiancing long round-trip latency when chaining many Solaris processs together with INET blocking sockets. On NT, I see little latency. Is there any way of tuning the solaris internals to make the socket respoonse times falster ? Is there an