简体   繁体   English

无法获取/socket.io/socket.io.js

[英]Cannot GET /socket.io/socket.io.js

<script src="/socket.io/socket.io.js"></script>

Why should we do this before setting the socket variable on the client side. 为什么要在客户端设置套接​​字变量之前这样做呢?

If I have client side script the given src file throws "Cannot GET /socket.io/socket.io.js" 如果我有客户端脚本,则给定的src文件将引发“无法获取/socket.io/socket.io.js”

Why should we do this before setting the socket variable on the client side. 为什么要在客户端设置套接​​字变量之前这样做呢?

Because that <script> tag is designed to load the client-side socket.io code which is required before you can initialize your client side socket.io connection. 因为该<script>标记旨在加载客户端socket.io代码,所以在初始化客户端socket.io连接之前这是必需的。

If I have client side script the given src file throws "Cannot GET /socket.io/socket.io.js" 如果我有客户端脚本,则给定的src文件将引发“无法获取/socket.io/socket.io.js”

If that URL does not work, then it means that your server is not properly configured with socket.io to serve the client-side file at that URL (which should be automatic if things are set up properly). 如果该URL不起作用,则意味着您的服务器未使用socket.io正确配置,无法通过该URL提供客户端文件(如果正确设置,该文件应该是自动的)。 We can only help you solve that server configuration when we can see the relevant server code to help advise on what is wrong there. 仅当我们看到相关的服务器代码以帮助建议那里的错误时,我们才能帮助您解决该服务器配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM