-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The problem that socket.io-client cannot be linked to the server in the react development environment #2427
Comments
hello |
你也碰到这个问题了嘛?我之前发过一次issues,案例不够被关了,这次发了这么久一直都没有人康康咋解决 |
坐等大神们解决了 |
I hit them same problem with socketio-client 2.xx. Vite do nothing and no error and no warning. |
这么久了还没官方的人回复一下😔 |
Hello @caohuiboss. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution! |
Currently the bot is just mentioning only the author of the issue 🤷 |
你试过低版本socket.io-client吗? 我发现socket.io-client 4.0 好像有点问题,但是我用 2.4.0的版本就可以 |
嗯,用npm init @vitejs/app my-vue-app --template vue 的项目,同样的代码吧packjson 里的socket.io-client换成2.4.0立马就通了,我也折腾了一天 |
老哥问题解决了没,我也遇到了这个问题,搞的我头都大了 |
降低版本就好了,socket.io-client 4.0好像有点问题,但是用2.4.0的版本就可以 |
import io from 'socket.io-client/dist/socket.io.js'; 试了有效 4.1.3 |
I think this issue is duplicate of #4798. |
Closing as it is highly likely a duplicate of #4798. |
以下是英文描述的问题 (The following is the problem described in English)
In the development environment(yarn dev):
In the react template, using socket.io-client to link the socket address does not respond, there is no error, there is no prompt message, and there is no prompt whether to connect or not. When I print the socket, it shows that contented is false.
But the link socket is valid in the following situations:
以下是中文描述的问题 (The following is the problem described in Chinese)
在开发环境中(yarn dev):
在react模板中,使用 socket.io-client链接socket地址并没有反应,没有任何报错,没有任何提示信息,是否连接都没提示,当我打印socket时候显示 contented 为false
但是以下情况链接socket是有效的:
Reproduction
这是简单的node服务 server.js (This is a simple node service server.js)
这是访问localhost:8080 打开的页面(This is the page opened by visiting localhost:8080)
这是我单独开启其他端口的一个简单html的页面来链接node的socket地址 (This is a simple html page where I opened other ports separately to link the socket address of node)
这是用react官方脚手架创建的项目 (This is a project created with react official scaffolding)
这是用vite创建的react项目 (This is a react project created with vite)
通过各个情况的比较,只有vite会有失败情况,应该是vite的问题了。
但是我想应该需要在vite.config.ts 配置,但是我在文档中没有找到此情况的解决方案。
Through the comparison of various situations, only vite will fail, which should be the problem of vite.
But I think it should be configured in vite.config.ts, but I did not find a solution for this situation in the documentation.
System Info
vite
version: ^2.0.5The text was updated successfully, but these errors were encountered: