I’m developing a Play application in Scala with a WebSocket server. This is the controller
class WebsocketServer {
def subscribe() = WebSocket.acceptWithActor[JsValue, JsValue]
{ request => out => <do something> }
}
This is the corresponding route:
GET /subscribe @controllers.WebsocketServer.subscribe()
I’ve implemented a Websocket client with a Java class (using javax.websocket) to do some tests with Specs2. I run Play application through running(FakeApplication()). The client class tries to connect to the web socket server through the method connect().
`public void connect() {
URI serverEndpointURI = URI.create("ws://localhost:9000/subscribe”);
try {
WebSocketContainer c = ContainerProvider
.getWebSocketContainer();
c.connectToServer(this, serverEndpointURI);
} catch (Exception e) {
throw new RuntimeException(e);
}
}`
But when I try to connect I have the following error:
java.net.ConnectException: Connection refused
Is it possible to connect my Java Websocket client to my web socket controller in FakeApplication()? Is the URI correct? Is 9000 the default port also for FakeApplication? Thanks.
Aucun commentaire:
Enregistrer un commentaire