Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4240

<f:websocket /> onopen eventhandler is called only the first time

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.3.1
    • 2.3.2
    • JSR-372
    • None
    • java 1.8, tomcat 9.0.8, Windows 10

    Description

      I use the socket below.

      <f:websocket id="usersocket" connected="false"
      onmessage="userSocketListener"
      onopen="userSocketOpened"
      onclose="userSocketClosed"
      onerror="alert('ERROR')"
      />

       

      If I call  jsf.push.open('usersocket')  and __ userSocketOpened() is called.

      Then I call   jsf.push.close('usersocket') and  userSocketClosed() is called.

      Then I call   jsf.push.open('usersocket')  and  userSocketOpened() is not called.

       

      I looked into myfaces-api-2.3.1-sources.jar!\META-INF\internal-resources\org.apache.myfaces.core.api\jsf.js and found the onopen eventhandler in line 283:

       

      socket.onopen = function(event) {
      if (reconnectAttempts == null) {
      var clientIds = clientIdsByTokens[channelToken];
      for (var i = clientIds.length - 1; i >= 0; i--){
      var socketClientId = clientIds[i];
      components[socketClientId]['onopen'](channel);
      }
      }
      reconnectAttempts = 0;
      }

      When the socket is opened the first time reconnectAttempts is null, when the socket is opened the second time reconnectAttempts is 0, so the line should be

      if (reconnectAttempts == null || reconnectAttempts == 0) 

      Attachments

        1. screenshot-1.png
          18 kB
          Harry Ring

        Activity

          People

            werpu Werner Punz
            Harry Ring Harry Ring
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: