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

Websockets are not initialised error #743

Open
SebastianFilip101 opened this issue Feb 24, 2022 · 3 comments
Open

Websockets are not initialised error #743

SebastianFilip101 opened this issue Feb 24, 2022 · 3 comments

Comments

@SebastianFilip101
Copy link

I am trying to create a WebSocket endpoint with Ninja and by following the documentation provided here I keep getting the same error. I followed the entire documentation step by step. This is the error:

[INFO] GCLOUD: java.lang.IllegalStateException: WebSockets are not enabled. Unable to configure route /api/websocketExample. Using implementation ninja.websockets.DefaultWebSockets

Because of this error the Routes are not initialised either.
Any Ideas?

@thibaultmeyer
Copy link
Contributor

thibaultmeyer commented Feb 24, 2022

Hello,

you are using the default implementation which is disabled by default. You have to create your own implementation.

https://github.com/ninjaframework/ninja/blob/develop/ninja-core/src/main/java/ninja/websockets/DefaultWebSockets.java

public class DefaultWebSockets implements WebSockets {

    @Override
    public boolean isEnabled() {
        return false;
    }
    
    @Override
    public void compileRoute(Route route) {
        throw new IllegalStateException("WebSockets are not enabled." + 
            " Unable to add websocket route to " + route.getUri() + "." + 
            " Are you running in a websocket-enabled HTTP server?");
    }
}

@SebastianFilip101
Copy link
Author

Is there a practical example of how a custom implementation should look like? Or how websockets are enabled?

@jjlauer
Copy link
Collaborator

jjlauer commented Feb 24, 2022 via email

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

3 participants