使用 Grails Spring Websocket 插件的主机名不能为空

host name can't be null using Grails Spring Websocket Plugin

我正在使用 spring 用于 grails 的 websocket 插件开发一个简单的网络应用程序。

虽然在本地一切正常,但在在线测试服务器上部署应用程序时,我收到了这些异常:

Chrome 控制台:

Error during WebSocket handshake: Unexpected response code: 500

Tomcat 控制台:

    java.lang.IllegalArgumentException: hostname can't be null
    at java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149)
    at java.net.InetSocketAddress.<init>(InetSocketAddress.java:216)
    at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
    at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
    at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
2015-02-07 19:18:26,382 [http-apr-8081-exec-1] ERROR errors.GrailsExceptionResolver  - IllegalArgumentException occurred when processing request: [GET] /innovaserver/stomp/611/hkjlpvdk/websocket
hostname can't be null. Stacktrace follows:
org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://109.168.108.18:8081/innovaserver/stomp/611/hkjlpvdk/websocket; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.IllegalArgumentException: hostname can't be null
    at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
    at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
    at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.IllegalArgumentException: hostname can't be null
    ... 6 more
Caused by: java.lang.IllegalArgumentException: hostname can't be null
    at java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149)
    at java.net.InetSocketAddress.<init>(InetSocketAddress.java:216)
... 6 more

我正在使用 Tomcat 7.55,Ubuntu 服务器

已解决!我必须在hosts文件中添加一个映射,将主机名映射到数据中心机器的私有IP。