【问题标题】:Why is SockJS incompatible?为什么 SockJS 不兼容?
【发布时间】:2019-05-09 08:31:03
【问题描述】:

当 sockjs 使用 websocket 协议时,我的应用程序运行良好。但我在服务器中收到错误:

Uncaught Error: Incompatibile SockJS! Main site uses: "1.3.0", the iframe: "1.0.0".

如何调试?

【问题讨论】:

    标签: spring websocket jackson stomp sockjs


    【解决方案1】:

    我通过在服务器端(Spring/Java)手动硬编码 SockJS 版本来修复它

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) 
    {
       registry.addEndpoint("/socket").setAllowedOrigins("*").withSockJS()
         .setClientLibraryUrl( "https://cdn.jsdelivr.net/npm/sockjs-client@1.3.0/dist/sockjs.min.js" ); //Added
    }
    

    jsDelivr – Open Source CDN

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 2017-02-07
      • 2017-10-08
      • 2014-11-06
      • 2018-01-26
      • 1970-01-01
      相关资源
      最近更新 更多