0
votes

I'm trying to use websocket using openshift and wildfly 8.1.

The application works on a local wildfly server on port 8080.

But, I'm not able to connect on openshift server for the websocket using port 8000.

Curriously, if I use port forwarding (rhc port-forward), I'm able to connect on the local forwarded port.

I think there is a missconfiguration for port forwarding on openshift.

Here is my code :

import javax.websocket.EncodeException;
import javax.websocket.CloseReason;
import javax.websocket.EndpointConfig;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.OnError;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

@ServerEndpoint("/ws/websocket")
public class WebSocketService{
    @OnOpen
    public void onOpen(Session peer, EndpointConfig config) {
        System.err.println("Open");
        peer.getAsyncRemote().sendText("Hello");
    }

    @OnClose
    public void onClose(Session peer, CloseReason reason) {
        System.err.println("Close");
    }

    @OnError
    public void onError(Session peer, Throwable throwable) {
        System.err.println("Error");
    }
}
1

1 Answers

2
votes

WildFly port on OpenShift should be 8080, not 8000 as you mentioned.

Are you able to connect to localhost:8080 and redirected to your OpenShift instance ?

Does Chrome Developer Tools show any errors ?