【问题标题】:socket.io "net::ERR_FAILED" with cache manifest for Progressive Web Appsocket.io "net::ERR_FAILED" 带有 Progressive Web App 的缓存清单
【发布时间】:2017-04-02 05:21:28
【问题描述】:

我正在开发一个渐进式 Web 应用程序,它使用 .manifest 文件来缓存客户端上的所有文件。我修改了此处的 socket.io 聊天示例:

https://github.com/socketio/chat-example

我的修改可以在这里找到:

https://github.com/TennisVisuals/socket.io.manifest.errors

客户端代码的第一个变化是:

  • 外部资源(jquery 和 socket.io 客户端库)在本地访问,而不是通过远程 URL。

一切都按预期进行。

但是有了第二个变化:

  • <html> 替换为 <html manifest="index.manifest">

应用程序失败,在 Javascript 控制台中出现此错误:

http://localhost:3000/socket.io/?EIO=3&transport=polling&t=Lij1LRo net::ERR_FAILED

初步修复

我已经能够通过添加以下行使其在本地工作:

enter var connectionOptions =  {
   "force new connection" : true,
   "reconnectionAttempts": "Infinity",
   "timeout" : 10000,
};
var socket = io(connectionOptions);

Cloudflare 和 Nginx

但是当我使用 Cloudflare 和 Nginx 运行时,我现在看到了奇怪的行为。

没有清单声明我得到一个错误,但一切仍然有效!

socket.io-1.7.2.js:7370 WebSocket connection to 'wss://hiveeye.net/socket.io/?EIO=3&transport=websocket&sid=rM2LKvCGJwaFx7RrAAAf' failed: Error during WebSocket handshake: Unexpected response code: 400

在添加清单声明后,它只运行一次,然后失败并出现以下错误:

socket.io-1.7.2.js:4948 GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5SC5&sid=rM2LKvCGJwaFx7RrAAAf net::ERR_FAILED
GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5STN net::ERR_FAILED
GET https://hiveeye.net/socket.io/?EIO=3&transport=polling&t=Lik5STN net::ERR_FAILED

我怀疑如果在没有清单的情况下运行时我可以让初始错误消失,那可能会解决问题......但我无法找到任何东西来帮助我解决这个问题......

【问题讨论】:

    标签: javascript socket.io cache-manifest


    【解决方案1】:

    好的,一旦我知道如何提出正确的问题,这真的很简单

    添加:

    NETWORK:
    *
    

    在清单文件的底部,一切正常。

    是的,“应用程序缓存”已弃用: https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache

    但我还是想让它工作!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-30
      • 2019-11-06
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 2019-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多