OpenShift:无法使用别名连接到WebSocket(错误)
我有一个使用WebSocket的Java Spring Web应用程序。HTML文件使用uri连接到WebSocket:OpenShift:无法使用别名连接到WebSocket(错误),websocket,openshift,spring-websocket,openshift-origin,java-websocket,Websocket,Openshift,Spring Websocket,Openshift Origin,Java Websocket,我有一个使用WebSocket的Java Spring Web应用程序。HTML文件使用uri连接到WebSocket: var wsUri = "wss://" + document.location.hostname + ":8443" + "/serverendpoint"; 以下是创建WebSocket的serverendpoint.java代码: package com.myapp.spring.web.controller
var wsUri = "wss://" + document.location.hostname + ":8443" + "/serverendpoint";
以下是创建WebSocket的serverendpoint.java代码:
package com.myapp.spring.web.controller;
import java.io.IOException;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.springframework.web.socket.server.standard.SpringConfigurator;
@ServerEndpoint(value="/serverendpoint", configurator = SpringConfigurator.class)
public class serverendpoint {
@OnOpen
public void handleOpen () {
System.out.println("JAVA: Client is now connected...");
}
@OnMessage
public String handleMessage (Session session, String message) throws IOException {
if (message.equals("ping")) {
// return "pong"
session.getBasicRemote().sendText("pong");
}
else if (message.equals("close")) {
handleClose();
return null;
}
System.out.println("JAVA: Received from client: "+ message);
MyClass mc = new MyClass(message);
String res = mc.action();
session.getBasicRemote().sendText(res);
return res;
}
@OnClose
public void handleClose() {
System.out.println("JAVA: Client is now disconnected...");
}
@OnError
public void handleError (Throwable t) {
t.printStackTrace();
}
}
当我使用URL连接到websocket时,websocket将连接。但是,当我为设置别名时(称为),websocket不会连接。为什么会这样?我在Google Chrome中收到以下错误消息:
此外,websocket在端口8443使用wss连接。这是一个相当于https的安全请求。因此,它如何处理作为http URL的URL,以及为什么不与别名连接
非常感谢你的帮助