灰熊/玻璃鱼-无法建立网络套接字握手 [英] Grizzly / Glassfish - Cant establish websockets handshake

查看:123
本文介绍了灰熊/玻璃鱼-无法建立网络套接字握手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让WebSockets在Grizzly/Glassfish上运行.我已经克隆了示例WebSockets聊天应用程序,并将其部署到Glassfish 3.1.2.但是,我无法使WebSockets连接. WebSockets握手失败,因为我收到405(不允许使用方法)响应.这是有道理的,因为Servlet中包含以下内容:

I'm trying to get WebSockets working on top of Grizzly / Glassfish. I've cloned the sample WebSockets chat application, built it and deployed it to Glassfish 3.1.2. However, I cannot get WebSockets to connect. The WebSockets handshake is failing because I'm getting a 405 (Method Not Allowed) response. This makes sense because of what is in the Servlet:

public class WebSocketsServlet extends HttpServlet {

    private final ChatApplication app = new ChatApplication();

    @Override
    public void init(ServletConfig config) throws ServletException {
        WebSocketEngine.getEngine().register(app);
    }

    @Override
    public void destroy() {
        WebSocketEngine.getEngine().unregister(app);
    }
}

没有指定doGet方法,所以我想知道是否某个地方需要更多配置,还是您需要自己在servlet doGet方法中实现握手逻辑?

There is no doGet method specified, so I'm wondering if there is more configuration required somewhere, or if you need to implement the handshake logic in the servlet doGet method yourself?

推荐答案

我试图在glassfish 3.1.2上使用grizzly-websockets-chat-2.1.9.war并得到相同的错误.

I was trying to use grizzly-websockets-chat-2.1.9.war on glassfish 3.1.2 and getting same error.

遵循了此页面上的建议

Followed the advice from this page http://www.java.net/forum/topic/glassfish/glassfish/websocket-connection-not-establishing-glasshfish-server-how-fix-it-0

指出要使用此处找到的版本(我认为该版本会表明它较旧,但是文件上的时间戳记为2012年1月30日):

which states to use the version found here (I would think the version would indicate it being older however the time stamps on the files are Jan 30 2012):

战争

来源

通过战争,一切正常.

对于那些喜欢使用glassfish Web控制台的用户.您可以通过以下方式启用网络套接字:

For those that like using the glassfish web console. You can enable web-sockets by:

配置">服务器配置">网络配置">协议">"http-listener-1",然后"HTTP"选项卡>滚动到底部并取消Websockets支持".

Configurations > server-config > Network Config > Protocols > http-listener-1, then HTTP tab > Scroll to bottom and check off Websockets Support.

Note Configurations> default-config> ...也具有相同的选项

Note Configurations > default-config > ... also has the same options

您可能会发现这个拥有更多候机楼的大陆.

You might find this more continent that keeping a terminal around.

这篇关于灰熊/玻璃鱼-无法建立网络套接字握手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆