socketio.emit() not working
See original GitHub issuehey 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:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It works! I used
python app.pyto run the app and everything is working now! Thanks!Okay, I’ll give it a go. Let’s see what happens!