简体   繁体   English

javax Websocket处理ping消息

[英]javax Websocket handle ping messages

I have a websocket server deployed on Glassfish 4. I try to use ping/pong. 我在Glassfish 4上部署了一个websocket服务器。我尝试使用ping / pong。 My plan is to send periodically pings from the server to the clients and if they do not pong back I wan to close the conenction. 我的计划是定期从服务器发送ping到客户端,如果他们不回来,我想关闭连接。 Unfortunately there seem not do be any 不幸的是似乎没有

@OnMessage
public void onMessage(PingMessage pingMessage)

within the javax.websocket.ClientEndpoint or ServerEndpoint. 在javax.websocket.ClientEndpoint或ServerEndpoint中。

Or any other way to react ping messages. 或任何其他方式来反应ping消息。 For some very strange reasons, when I deploy the server inside Eclipse I receive pong messages even though I never implemented it inside the client. 出于一些非常奇怪的原因,当我在Eclipse中部署服务器时,我收到了pong消息,即使我从未在客户端中实现它。 But when I deploy it using the glassfish maven plugin on my server, I dont receive any pongs anymore. 但是当我在服务器上使用glassfish maven插件部署它时,我再也不会收到任何pongs。

It turned out that the server part was not fully deployed which caused the wierd difference between ecplise and the server. 原来,服务器部分没有完全部署,导致ecplise和服务器之间的差异。 But anyway, it is still strange that you cannot handle the ping messages yourself. 但无论如何,你自己无法处理ping消息仍然很奇怪。 Imagine that you want to handle it or use it for sending status or something... 想象一下,你想要处理它或用它来发送状态或什么......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM