You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Werner Punz (JIRA)" <de...@myfaces.apache.org> on 2018/06/19 10:28:00 UTC

[jira] [Comment Edited] (MYFACES-4240) onopen eventhandler is called only the first time

    [ https://issues.apache.org/jira/browse/MYFACES-4240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16516918#comment-16516918 ] 

Werner Punz edited comment on MYFACES-4240 at 6/19/18 10:27 AM:
----------------------------------------------------------------

this is very likely due to the reconnectAttemts not being initialized at variable declaration.

 


was (Author: werpu):
The socket code is not from me, but my 2c, this is very likely browser or server specific behavior, I can file the patch in after work, if someone has time left earlier then feel free.

 

> <f:websocket /> onopen eventhandler is called only the first time
> -----------------------------------------------------------------
>
>                 Key: MYFACES-4240
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4240
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-372
>    Affects Versions: 2.3.1
>         Environment: java 1.8, tomcat 9.0.8, Windows 10
>            Reporter: Harry Ring
>            Priority: Critical
>
> 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) {_
>  _{color:#d04437}if (reconnectAttempts == null) {color}{_
>  _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)_ 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)