Can't connect to WebSocket inside Service Worker

谁说胖子不能爱 提交于 2019-12-08 06:01:36

问题


Can't connect to WebSocket inside Service Worker!

ws = new WebSocket("ws://46.101.***.***");

Response

(Opcode -1)


回答1:


As shown in this GitHub issue on the W3C service worker repo, service workers do not support WebSocket.




回答2:


I think you can create a web-socket connection inside a service worker. Or you can use web-workers here to maintain the websocket.



来源:https://stackoverflow.com/questions/41353796/cant-connect-to-websocket-inside-service-worker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!