socketio.emit() not working

See original GitHub issue

hey I need the server to be the originator of a message when an entry is inserted into the database. I have this line in my app.py file

@app.route('/pet', methods=['GET'])
def insertPet():
...conducting insert in database...
socketio.emit('inserted_pet', {details: details}, broadcast=True)
return render_template('index.html')

on subscribe.html (using angularjs) where I have registered a listener as follows: socket.on('inserted_pet', function(results){ console.log(results); }); All I see are some http 400 errors in the browser console. Nothing shows up… now the thing is… on connect works so this means I have things correctly set up:

@socketio.on('connect')
def on_connect():
    emit('test', {"test": "lmao"}, broadcast=True) 
    pass

in subscribe.html:

socket.on('connect', function() {
	socket.emit('connect');
});
socket.on('test', function(results){
	console.log(results);
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Dobermenschcommented, Aug 13, 2018

It works! I used python app.py to run the app and everything is working now! Thanks!

0reactions
Dobermenschcommented, Aug 13, 2018

Okay, I’ll give it a go. Let’s see what happens!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js, Socket.io emit not working - Stack Overflow
So I had issues with socket.emit not firing to the socket that made the initial request out. The issue was not an issue,...
Read more >
socket.io emit not working · Issue #3840 - GitHub
I am using socket.io client and server(nodejs) on connect I am using emit but it is not doing anything my server code const...
Read more >
Emitting events | Socket.IO
You can add a callback as the last argument of the emit() , and this callback will be called once the other side...
Read more >
Getting Started — Flask-SocketIO documentation
When working with namespaces, send() and emit() use the namespace of the ... Note that socketio.send() and socketio.emit() are not the same functions...
Read more >
io.emit() not emitting data to all clients : r/node - Reddit
This would have been a very simple thing to do had you have used websockets, whilst also learning about how sockets work. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found