2
SparkJava 웹 소켓이 작동하지 않습니다. 'ws : // localhost : 4567/echo'에서 websocket 테스터로 연결할 때마다 'undefined'오류가 발생하고 연결되지 않으며 sout 또는 printStackTrace가 호출되지 않습니다.SparkJava 웹 소켓이 작동하지 않습니다.
@WebSocket
public class EchoWebSocket {
private static final Queue<Session> sessions = new ConcurrentLinkedQueue<>();
@OnWebSocketConnect
public void connected(Session session) {
System.out.println("Client connected");
//sessions.add(session);
}
@OnWebSocketClose
public void closed(Session session, int statusCode, String reason) {
System.out.println("Client disconnected");
//sessions.remove(session);
}
@OnWebSocketMessage
public void message(Session session, String message) throws IOException {
System.out.println("Got: ");// + message); // Print message
//session.getRemote().sendString(message); // and send it back
}
@OnWebSocketError
public void throwError(Throwable error) {
error.printStackTrace();
}
}
내가 그것을
Spark.webSocket("/echo", new EchoWebSocket());
Spark.init();
재현 할 수 없습니다. 여기서 제공 한 코드를 사용하고 있습니까? 그것은 내 컴퓨터에서 아무 문제없이 작동합니다. – Selim