2016-02-04 2 views
0

dans flask-socketio, est-il possible de forcer le transport à être seulement socket Web?flask-socketio: limiter le transport à websocket seulement

Selon le protocole d'origine:

https://github.com/socketio/engine.io 
transports (<Array> String): transports to allow connections to (['polling', 'websocket']) 

Mon but serait de se débarrasser de l'appel HTTP d'origine.

Best,

Répondre

1

Voir ce post - Socket.io 1.x: use WebSockets only?

Il semble que vous ne pouvez pas vous débarrasser de l'appel HTTP original, mais vous pouvez dire au client de ne pas utiliser de longue interrogation.

var socket = io({transports: ['websocket']}); 

Je ne trouve pas un moyen de le désactiver du côté serveur avec Flask-SocketIO.

0

Selon la documentation de Flask-SoskcetIO, vous pouvez utiliser async_mode pour définir async_mode. Si vous avez installé eventlet ou gevent avec gevent-websocket, le Websocket sera utilisé en premier.

 async_mode: The asynchronous model to use. See the Deployment 
        section in the documentation for a description of the 
        available options. Valid async modes are 
        ``threading``, ``eventlet``, ``gevent`` and 
        ``gevent_uwsgi``. If this argument is not given, 
        ``eventlet`` is tried first, then ``gevent_uwsgi``, 
        then ``gevent``, and finally ``threading``. The 
        first async mode that has all its dependencies installed 
        is then one that is chosen.