Websocket example won't work

后端 未结 1 944
执笔经年
执笔经年 2021-01-01 23:52

I try run this example:

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.websocket.OnClose;
import javax.websocket.OnError;
impo         


        
1条回答
  •  灰色年华
    2021-01-02 00:21

    I had the same problem trying to use WebSocket API on Tomcat 7.0.47. The error message being displayed client side wasn't any help at all and my server side endpoint was never being created.

    After much wasted time I found it was due to way I had set the dependency for javax.websocket-api. I'm using Maven which has the default scope as compile which causes problems as Tomcat has the websocket-api.jar in its lib folder. Setting the dependency to provided solved it.

        
          javax.websocket
          javax.websocket-api
          1.0
          provided
        
    

    Hope this helps

    It's also worth noting that if running behind Apache you will need mod_proxy_wstunnel and if using IIS you will need version 8.0 as anything prior does not support websockets.

    0 讨论(0)
提交回复
热议问题