gpt4 book ai didi

I cant make socket.on connection successfully in react native(我无法在本机Reaction中创建套接字。连接成功)

转载 作者:bug小助手 更新时间:2023-10-25 10:36:27 28 4
gpt4 key购买 nike



I'm trying to create a mini chat app so I need to use socket connection but I can't make the connection. I tried many things but nothing solved my problem.

我正在尝试创建一个迷你聊天应用程序,所以我需要使用套接字连接,但我无法进行连接。我试了很多办法,但都没有解决我的问题。


My index.js file:

我的index.js文件:


 var  express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
app.get('/', function(req, res){
res.send('Hello');
});
server.listen(3000);

Other that I'm using detail.js file:

另外,我使用的是Detail.js文件:


import io from 'socket.io-client/dist/socket.io';
componentDidMount(){

var socket = io('http://localhost:3000',connectionConfig);
socket.on('connect',function(){
console.log('connected');
})
}

When I open debugging page, 'connected' doesn't show up

当我打开调试页面时,‘已连接’没有显示


更多回答
优秀答案推荐
更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com