Hello guys. In my WebSocket application, the WS server need to handle three kinds of message: DataPkg, SigPkg and WS_SigPkg. The DataPkg is binary for user data, with controller headers; the SigPkg is String for user data control between WS clients, and the WS_SigPkg is also String for such as registration to WS server and switching of DataPkg and SigPkg between different WS sessions.
So I put six encoder/decoders:
decoders = {SigDecoder.class, WS_SigDecoder.class, DataDecoder.class},
encoders = {SigEncoder.class, WS_SigEncoder.class, DataEncoder.class}
Then I got bellow error:
Caused by: javax.servlet.ServletException: Web socket server initialization failed.
at org.glassfish.tyrus.servlet.TyrusServletFilter.init(TyrusServletFilter.java:126)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:131)
... 28 more
Caused by: javax.websocket.DeploymentException: Class org.sample.xyzserver.XyzServer. Text MessageHandler already registered.
Seems the GlashFish Server 4.1.1 cannot add two MessageHandlers for the String messages, though in the upper layer they are different and the decoders can find that.
Is here any miss-understanding or there is a easy work-around, or I have to refactor to use only one MessageHandler for string and one for binary? Thanks.