socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

socketio unable to send msg to client

Open Set4now opened this issue 6 years ago • 1 comments

for testing purpose i was using the generic flask start methods. cat app.py

from flask_socketio import SocketIO, emit, disconnect
app = Flask(__name__)
app.debug = True
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

...... codes.....
def send_msg(event, msg):
    socketio.emit(event, msg, broadcast=True) 

if __name__ == "__main__":
    #app.run()
    socketio.run(app)

and it's working as expected..

But the problem happens when am trying to use it in our stage env where we already have existing project structure. may be am unable to use or set it properly

Stage project structure :- cd myproject bin build build-tools Config configuration DEVELOPMENT.md doc etc manage.py README.md runpy setup.cfg setup.py setup.pybak src test var

all the src codes are inside src folder

cat manage.py

from OpenSSL import crypto
from iprojectname import app
import os, stat, random
import argparse
from flask_socketio import SocketIO
socketio = SocketIO(app)
    # app.run(**params)
    socketio.run(app,**params)

in src/projectname directory alarming_class.py constant.py get_variables_dualcontroller.py main.py nsm_client.py static wibutils.py carnaval_alarm.py dbconn.py get_variables.py mcm_generate.py osUpgrade.py templates config_generator.py get_dualcontroller_vlan.py init.py monitor_portal.py pycache utils.py

the init.py has all the existing routes functions. for my work i have created a blueprint (osUpgrade.py)

cat init.py

.....
from .osUpgrade import blueprint as osupgrade
app.register_blueprint(osupgrade, url_prefix='')
......

cat osUpgrade.py

from flask_socketio import SocketIO, emit, disconnect
def send_msg(event, msg):
    print ("working")
    emit(event, msg)

I have also setup the ajax javascript... Now when i send request in the browser with debugger mode..i see clients getting connected to socketio and same with flask but am unable to see those messages in the UI.

May i am not able to understand how to set this up. Any help or suggestion would be appreciated.

Set4now avatar Feb 06 '20 05:02 Set4now

Closed due to inactivity, please reopen if needed.

darrachequesne avatar Feb 24 '21 06:02 darrachequesne