Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSF 2.3.15: Websocket trying to reconnect infinitely instead of finitely (because of browser specific bug) #4933

Closed
Toru47 opened this issue May 19, 2021 · 2 comments

Comments

@Toru47
Copy link

Toru47 commented May 19, 2021

As said in #4572 (comment) the websocket bug "Websocket trying to reconnect infinitely instead of finitely (because of browser specific bug)" is obviously not fixed in version 2.3.15. I've tried this version in WildFly 21.0.0.Final added 2.3.15 Mojarra manually with the same error result. This error occurs if the application is (hot) redeployed in Eclipse:

websocket
websocket2

Test with Eclipse 4.18, WildFly 21.0.0.Final with manually added JSF 2.3.15 Mojarra, Firefox 62.0.3 or MS Edge 90.0.818

Bean:

@Named
@SessionScoped
public class FooBean implements Serializable {
    private static final long serialVersionUID = -9057373496036307133L;
    @Inject
    @Push
    private PushContext fooChannel;

    public void test() {
        fooChannel.send("Test");
    }
}

Facelet:

<f:websocket channel="fooChannel" onmessage="function(m){ ... }" scope="session" />

It doesn't matter if the bean is ViewScoped or SessionScoped.

@BalusC
Copy link
Contributor

BalusC commented May 23, 2021

Reproduced. This is after all not a problem in client side, let alone a "browser specific bug". It happens in every single browser. This is after all actually a problem in server side. The server log shows an infinite loop of

java.lang.NullPointerException
	at com.sun.faces.cdi.CdiUtils.getBeanReferenceByType(CdiUtils.java:221)
	at com.sun.faces.cdi.CdiUtils.getBeanReference(CdiUtils.java:204)
	at com.sun.faces.push.WebsocketSessionManager.getInstance(WebsocketSessionManager.java:268)
	at com.sun.faces.push.WebsocketEndpoint.onOpen(WebsocketEndpoint.java:65)

The technical problem is, it was expecting to find the CDI bean manager in FacesContext, but there is no FacesContext anywhere at the moment the websocket hits the server.

Have you checked the server log?

It worked in OmniFaces <o:socket> because it uses CDI.current().getBeanManager() but this was nowhere used in Mojarra.

BalusC added a commit that referenced this issue May 23, 2021
JNDI can be configured app-wide while CDI#current() is server-wide
arjantijms added a commit that referenced this issue May 23, 2021
…socket-infinite-loop-after-server-restart

Fix #4933: use CDI#getBeanManager() as fallback to get BeanManager
@Toru47
Copy link
Author

Toru47 commented Jun 8, 2021

I haven't got any errors in server log, not even in debug mode.

Now I've build this fixed version (Mojarra 2.3.16-SNAPSHOT) with eb19b93 and run in WildFly 21.0.0.Final

08:46:10,346 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 81) Mojarra 2.3.16-SNAPSHOT...

but the issue is not fixed. After doing a

[standalone@localhost:9990 /] reload

and reload the page the server floods the browser with the requests mentioned above - infinitely long and the browser consumes a lot of CPU. If I close the browser and open it again with that page, the problem still exists. So, closing and opening the browser is not a solution to stop that flooding. Only the stopping of the server will stop that flooding.

Moreover the problem seems to be browser and session independent. If I open another browser along with the first one that error occurs in the second browser, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants