Replies: 2 comments
-
|
添加 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
这是来自QQ邮箱的假期自动回复邮件。你好,邮件已经收到,我会尽快回复你。
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
请确保提供下面的信息:
JS:
const socket = io();
socket.on('user count', function (data) {
console.log('js登录', data.user_name);
$('#online_count').html(data.count);
});
Python:
online_users = []
@socketio.on('connect')
def connect():
global online_users
user_id = session.get('user_id')
one_user = User.query.get(user_id)
if user_id not in online_users:
online_users.append(user_id)
print('connect登录', len(online_users), one_user.user_name)
emit('user count', {'count': len(online_users), 'user_name': one_user.user_name, 'connect_is': 0}, broadcast=True)
@socketio.on('disconnect')
def disconnect():
global online_users
user_id = session.get('user_id')
one_user = User.query.get(user_id)
if user_id in online_users:
online_users.remove(user_id)
print('disconnect退出', len(online_users), one_user.user_name)
emit('user count', {'count': len(online_users), 'user_name': one_user.user_name, 'connect_is': 0}, broadcast=True)
前端报错:
polling-xhr.js:264 GET http://xingyezn.cn/socket.io/?EIO=3&transport=polling&t=NK7PRDj&sid=b6cca4b760404bd9b48aec1a61aec1b8 400 (BAD REQUEST)
后端报错:
[pid: 14861|app: 0|req: 5/45] 180.160.58.153 () {34 vars in 772 bytes} [Thu Oct 8 16:47:55 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PJRn => generated 187 bytes in 6 msecs (HTTP/1.1 200) 3 headers in 170 bytes (1 switches on core 0)
[pid: 14860|app: 0|req: 10/46] 180.160.58.153 () {34 vars in 846 bytes} [Thu Oct 8 16:47:55 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PJSO&sid=829bf44f20824b9cabf44d1b19eb258c => generated 11 bytes in 0 msecs (HTTP/1.1 400) 2 headers in 94 bytes (1 switches on core 0)
[pid: 14857|app: 0|req: 9/47] 180.160.58.153 () {40 vars in 939 bytes} [Thu Oct 8 16:47:56 2020] POST /socket.io/?EIO=3&transport=polling&t=NK7PJhN&sid=829bf44f20824b9cabf44d1b19eb258c => generated 11 bytes in 0 msecs (HTTP/1.1 400) 3 headers in 143 bytes (1 switches on core 0)
[pid: 14859|app: 0|req: 9/48] 180.160.58.153 () {34 vars in 772 bytes} [Thu Oct 8 16:47:57 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PJx3 => generated 187 bytes in 3 msecs (HTTP/1.1 200) 3 headers in 170 bytes (1 switches on core 0)
[pid: 14860|app: 0|req: 11/49] 180.160.58.153 () {34 vars in 846 bytes} [Thu Oct 8 16:47:57 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PJxd&sid=7fd2c758d3174423a3755279c5db7b15 => generated 11 bytes in 0 msecs (HTTP/1.1 400) 2 headers in 94 bytes (1 switches on core 0)
[pid: 14857|app: 0|req: 10/50] 180.160.58.153 () {40 vars in 939 bytes} [Thu Oct 8 16:47:58 2020] POST /socket.io/?EIO=3&transport=polling&t=NK7PKAg&sid=7fd2c758d3174423a3755279c5db7b15 => generated 11 bytes in 0 msecs (HTTP/1.1 400) 3 headers in 143 bytes (1 switches on core 0)
[pid: 14858|app: 0|req: 7/51] 180.160.58.153 () {34 vars in 772 bytes} [Thu Oct 8 16:47:59 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PKQG => generated 187 bytes in 4 msecs (HTTP/1.1 200) 3 headers in 170 bytes (1 switches on core 0)
[pid: 14860|app: 0|req: 12/52] 180.160.58.153 () {34 vars in 846 bytes} [Thu Oct 8 16:47:59 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PKQo&sid=6ac96af010e9463d8934f08d8d9737dd => generated 11 bytes in 0 msecs (HTTP/1.1 400) 2 headers in 94 bytes (1 switches on core 0)
[pid: 14857|app: 0|req: 11/53] 180.160.58.153 () {40 vars in 939 bytes} [Thu Oct 8 16:48:00 2020] POST /socket.io/?EIO=3&transport=polling&t=NK7PKfp&sid=6ac96af010e9463d8934f08d8d9737dd => generated 11 bytes in 0 msecs (HTTP/1.1 400) 3 headers in 143 bytes (1 switches on core 0)
[pid: 14860|app: 0|req: 13/54] 180.160.58.153 () {34 vars in 772 bytes} [Thu Oct 8 16:48:01 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PKve => generated 187 bytes in 4 msecs (HTTP/1.1 200) 3 headers in 170 bytes (1 switches on core 0)
[pid: 14857|app: 0|req: 12/55] 180.160.58.153 () {34 vars in 846 bytes} [Thu Oct 8 16:48:01 2020] GET /socket.io/?EIO=3&transport=polling&t=NK7PKw9&sid=6612fd1e26e54f398fbe88a9835250d9 => generated 11 bytes in 0 msecs (HTTP/1.1 400) 2 headers in 94 bytes (1 switches on core 0)
[pid: 14861|app: 0|req: 6/56] 180.160.58.153 () {40 vars in 939 bytes} [Thu Oct 8 16:48:02 2020] POST /socket.io/?EIO=3&transport=polling&t=NK7PL9C&sid=6612fd1e26e54f398fbe88a9835250d9 => generated 11 bytes in 0 msecs (HTTP/1.1 400) 3 headers in 143 bytes (1 switches on core 0)
就是这样一直反复报错。不知道怎么解决。本地的时候也没有报错。
Beta Was this translation helpful? Give feedback.
All reactions