Official repository for gevent-socketio

Overview

Presentation

https://secure.travis-ci.org/abourget/gevent-socketio.png?branch=master

gevent-socketio is a Python implementation of the Socket.IO protocol, developed originally for Node.js by LearnBoost and then ported to other languages. Socket.IO enables real-time web communications between a browser and a server, using a WebSocket-like API. One aim of this project is to provide a single gevent-based API that works across the different WSGI-based web frameworks out there (Pyramid, Pylons, Flask, web2py, Django, etc...). Only ~3 lines of code are required to tie-in gevent-socketio in your framework. Note: you need to use the gevent python WSGI server to use gevent-socketio.

Community, rise up!

ANNOUNCEMENT: This project is in need of a solid maintainer to navigate through the 27+ open Pull Requests, merge what needs to be merged, and continue on with newer developments. @abourget is not putting as much time as he'd like on this project these days. This project has nearly 1000 GitHub Stars.. it's used by major corporations. It's a great project for you to lead. Contact me on Twitter @bourgetalexndre to take more leadership.

Technical overview

Most of the gevent-socketio implementation is pure Python. There is an obvious dependency on gevent, and another on gevent-websocket. There are integration examples for Pyramid, Flask, Django and BYOF (bring your own framework!).

Documentation and References

You can read the renderered Sphinx docs at:

Discussion and questions happen on the mailing list:

or in the Github issue tracking:

You can also contact the maintainer:

Installation

You can install with standard Python methods:

pip install gevent-socketio

or from source:

git clone git://github.com/abourget/gevent-socketio.git
cd gevent-socketio
python setup.py install

For development, run instead of install:

python setup.py develop

If you want to do all of that in a virtualenv, run:

virtualenv env
. env/bin/activate
python setup.py develop   # or install

To execute all tests, run:

tox

To execute all tests for a specific Python version, run something like:

tox -e py27

To execute a specific test for a specific Python version, run something like:

tox -e py27 -- test_packet.py::TestEncodeMessage::test_encode_event
Comments
  • Any idea how to use a different namespace other than

    Any idea how to use a different namespace other than "socket.io" ?

    I tried to change the namespace from "socket.io" to another string and the framework does not work. Any ideas where are all the places where I have to make changes? I thought it is only the constructor on the server side

    
    SocketIOServer(('127.0.0.1', 8080), app,
            namespace="newnamespace", policy_server=False).serve_forever()
    

    And on the client

    
    
    // socket.io specific code
    var socket = io.connect("http://localhost:8080/newnamespace", { resource : "newnamespace"
    });
    
    
    opened by vivekhub 13
  • gunicorn --access-logfile not working

    gunicorn --access-logfile not working

    Hi guys,

    When I use the worker socketio.sgunicorn.GeventSocketIOWorker gunicorn doesn't log access logs. The file is created but its always empty.

    Any ideas?

    opened by marconi 12
  • live_cpu_graph does not work on Internet Explorer

    live_cpu_graph does not work on Internet Explorer

    Here is the error from IE 8 browser - its triggers a JS exception

    Webpage error details
    
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; InfoPath.2; BOIE8;ENUS)
    Timestamp: Fri, 6 Jul 2012 08:24:29 UTC
    
    
    Message: 'window.G_vmlCanvasManager' is null or not an object
    Line: 698
    Char: 17
    Code: 0
    URI: http://localhost:8080/static/jquery.flot.js
    
    opened by vivekhub 12
  • Socket.io 1.0 release

    Socket.io 1.0 release

    It appears that socket.io 1.0 has been released: http://socket.io/blog/introducing-socket-io-1-0/

    There are new protocols: https://github.com/automattic/engine.io-protocol and https://github.com/automattic/socket.io-protocol

    opened by matteosuppo 11
  • Add transports class variable to gunicorn workers to allow setting transports

    Add transports class variable to gunicorn workers to allow setting transports

    Nginx is often put in front of other webservers, but does not support web-sockets. This is generally fine, however if using the gunicorn worker, you cannot unset the websocket transport. This causes a traceback about a missing wsgi.web_socket key. There is already a closed issue about this.

    Additionally, I added an Nginx specific worker class which sets the transport to xhr-polling. This appears to be the only transport which is currently working. It appears that there are several broken transports.

    opened by berndtj 11
  • Serving in uWSGI

    Serving in uWSGI

    How do I serve my Django site using uWSGI with the SocketIOServer? I tried using the following uwsgi config:

    [uwsgi]
    socket = 127.0.0.1:3031
    master = true
    processes = 2
    env = DJANGO_SETTINGS_MODULE=demo.settings
    module = run
    

    and I have run.py:

    from gevent import monkey
    from socketio.server import SocketIOServer
    import django.core.handlers.wsgi
    import os
    import sys
    
    monkey.patch_all()
    
    PORT = 3031
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings'
    
    application = django.core.handlers.wsgi.WSGIHandler()
    SocketIOServer(('', PORT), application, namespace="socket.io").serve_forever()
    

    but it just keeps on loading. Any ideas on how I might tell uWSGI to use SocketIOServer for serving my app?

    opened by marconi 9
  • RoomMixin deliveres the same message multiple times

    RoomMixin deliveres the same message multiple times

    If I run my server with n worker, and I connect n+1 clients, emit_to_room delivers the same message multiple times to every client.

    Steps to reproduce:

    1. run your server with n workers.
    2. connect n+1 clients and make them join the same channel
    3. push a message with emit_to_room

    This is the code that I'm using (please ignore my re-implementation of emit_to_room there).

    I would like for someone to confirm it's actually a bug and not just me. If it's actually a bug, I am ready submit a pull request.

    opened by fcurella 9
  • Leaks?

    Leaks?

    It looks to me from running the simple chat example (and other applications) under Dozer (https://bitbucket.org/bbangert/dozer) that gevent-socketio is leaking a socketio.virtsocket.Socket and geventwebsocket.websocket.WebSocketHybi on every disconnect (along with a host of related/connected gevent/greenlet things).

    The problem, as best as I can see, is that although kill() runs when the socket disconnects, the socket itself is never actually disposed of. From looking at the dozer output it seems like the problem may be that the environ dict is never deleted, so references remain to the websocket and socketio objects. I don't know if that's right (or even reasonable), or what to do to fix it.

    opened by jpellerin 8
  • pip repositories on pypy are very outdated - V 0.3

    pip repositories on pypy are very outdated - V 0.3

    When i do a pip install gevent-socketio on a new box, I get a really old version of gevent-socketio. Here is what I see

    gevent==0.13.8
    gevent-socketio==0.3
    gevent-websocket==0.3.6
    greenlet==0.4.1
    

    Any idea why? This is more than a year old code and bug fixes that I contributed a year ago are missing.

    opened by vivekhub 7
  • Client Disconnects

    Client Disconnects

    I am trying to use gevent-socketio to perform some tasks a remote server running the python script that uses gevent-socketio . I am using socketio in as a web client. I have based this on the simple chat example. I have the client talking to the server and I and can get the server to print messages and do basic actions when a button is pressed on the web interface. However, when I run a long or CPU intensive (I don’t know which is the cause) operation on the def on_yyy event the clients get disconnected. Any ideas? Many Thanks Edd

    opened by edd-natstar 7
  • socketio does not exist in request.environ dictionary

    socketio does not exist in request.environ dictionary

    I am using gunicorn with a socketio.sgunicorn.GeventSocketIOWorker worker to run a django project. When a websocket request arrives, the "socketio" key does not appear in the request.environ dictionary. What can be the reason for that?

    The request.environ dictionary:

    {'HTTP_COOKIE': 'csrftoken=ou3ptkud0jYBsJ9hKVmQfhQVcI2a9Xiu; sessionid=3cccb6f0e3a18dac0a4b53f9880eea3d', 'SERVER_SOFTWARE': 'gevent/0.13 Python/2.7', 'SCRIPT_NAME': u'', 'REQUEST_METHOD': 'GET', 'PATH_INFO': u'/socket.io/websocket', 'HTTP_ORIGIN': 'http://127.0.0.1:8000', 'SERVER_PROTOCOL': 'HTTP/1.0', 'QUERY_STRING': '', 'HTTP_SEC_WEBSOCKET_EXTENSIONS': 'x-webkit-deflate-frame', 'HTTP_CONNECTION': 'Upgrade', 'SERVER_NAME': 'localhost', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.url_scheme': 'http', 'SERVER_PORT': '8000', 'HTTP_UPGRADE': 'websocket', 'wsgi.input': <gevent.pywsgi.Input object at 0x8da33ec>, 'HTTP_HOST': '127.0.0.1:8000', 'wsgi.multithread': False, 'HTTP_SEC_WEBSOCKET_VERSION': '13', 'wsgi.version': (1, 0), 'GATEWAY_INTERFACE': 'CGI/1.1', 'wsgi.run_once': False, 'wsgi.errors': <open file '', mode 'w' at 0xb74db0d0>, 'wsgi.multiprocess': False, 'HTTP_SEC_WEBSOCKET_KEY': 'PYVCqrOJSn1N90lN0igPuA==', 'CSRF_COOKIE': 'ou3ptkud0jYBsJ9hKVmQfhQVcI2a9Xiu'}

    opened by jewishop 7
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • examples/live_cpu_graph/live_cpu_graph/static/excanvas.js
    • examples/pyramid_backbone_redis_chat/chatter3/static/backbone.js
    • examples/pyramid_backbone_redis_chat/chatter3/static/handlebars.js
    • examples/pyramid_backbone_redis_chat_persistence/chatter4/static/backbone.js
    • examples/pyramid_backbone_redis_chat_persistence/chatter4/static/handlebars.js
    • examples/simple_pyramid_chat/chatter2/static/backbone.js
    • examples/simple_pyramid_chat/chatter2/static/handlebars.js
    • examples/testapp/testapp/static/backbone.js
    • examples/testapp/testapp/static/handlebars.js
    • socketio/virtsocket.py
    • tests/jstests/static/qunit.js

    Fixes:

    • Should read retrieve rather than retreive.
    • Should read preferred rather than prefered.
    • Should read suppress rather than surpress.
    • Should read function rather than funtion.
    • Should read dealt rather than dealth.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Henok alem py2 to py3

    Henok alem py2 to py3

    All tests passing with 33% test coverage:

    ---------- coverage: platform darwin, python 3.6.5-final-0 -----------
    Name                       Stmts   Miss  Cover
    ----------------------------------------------
    socketio/__init__.py          19     14    26%
    socketio/defaultjson.py       15      1    93%
    socketio/handler.py          105    105     0%
    socketio/mixins.py            30     30     0%
    socketio/namespace.py        134     27    80%
    socketio/packet.py           117      0   100%
    socketio/policyserver.py      19     19     0%
    socketio/sdjango.py           45     45     0%
    socketio/server.py            90     90     0%
    socketio/sgunicorn.py        109    109     0%
    socketio/transports.py       180    180     0%
    socketio/virtsocket.py       214    102    52%
    ----------------------------------------------
    TOTAL                       1077    722    33%
    
    opened by henokalem 0
  • KeyError: 'socketio' in socketio_manager

    KeyError: 'socketio' in socketio_manager

    I use the example of simply_pyramid_chat for your project. I started a project with pserve pyramid, use view.py from the example. But I received KeyError: 'socketio' in socketio.init.py socketio_manager line 67

    def socketio_service(request):
        socketio_manage(request.environ, {'/chat': TestNamespace}, request=request)
    
        return Response('')
    

    reques.environ has no attribute 'socketio'

    reques.environ

    <class 'dict'>: {'SERVER_NAME': 'debian', 'HTTP_HOST': '0.0.0.0:6543', 'SCRIPT_NAME': '', 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', 'SERVER_PORT': '6543', 'webob.is_body_seekable': True, 'webob._cache_control': ('', <CacheControl ''>), 'wsgi.errors': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>, 'SERVER_PROTOCOL': 'HTTP/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'REMOTE_PORT': '38674', 'HTTP_ACCEPT_LANGUAGE': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3', 'webob._parsed_cookies': ({}, ''), 'wsgi.url_scheme': 'http', 'wsgi.multiprocess': False, 'wsgi.input': <_io.BytesIO object at 0x7ff315d61200>, 'webob._parsed_query_vars': (GET([]), ''), 'wsgi.run_once': False, 'QUERY_STRING': '', 'SERVER_SOFTWARE': 'waitress', 'HTTP_UPGRADE_INSECURE_REQUESTS': '1', 'REMOTE_ADDR': '127.0.0.1', 'wsgi.input_terminated': True, 'CONTENT_LENGTH': '0', 'HTTP_CONNECTION': 'keep-alive', 'wsgi.version': (1, 0), 'PATH_INFO': '/socket.io/chat', 'wsgi.file_wrapper': <class 'waitress.buffers.ReadOnlyFileBasedBuffer'>, 'REMOTE_HOST': '127.0.0.1', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'wsgiorg.routing_args': ((), {}), 'wsgi.multithread': True, 'REQUEST_METHOD': 'GET'}
    

    What could be the problem? Thanks!

    opened by ChmutovSergey 0
  • Is it possible to use gevent-socketio as a socket.io client?

    Is it possible to use gevent-socketio as a socket.io client?

    I need to talk with a socket.io server -- it it possible to use gevent-socketio as a client, connecting to a websocket on a server and then exchanging realtime messages?

    opened by garyo 1
  • Release 0.3.7 with post-0.3.6 fixes?

    Release 0.3.7 with post-0.3.6 fixes?

    Hi!

    There seem to be a number of post-0.3.6 commits in Git that never got to PyPI. (The fix I'd need in a release is 12da9667deba432d8917129afab1daa86c20ec84 in particular.) I find these unreleased fixes in Git:

    • git cherry -v 668d11edbd62052cde1583be1e1d0512c930f16d | tac
      • 0e1d9d5d461530724522d12d592cde9fc68264a9 Add support for Django 1.10
      • 9a6e024e056964c3d860316d5b13b295ed80d379 Drop support for Django 1.3
      • a76b50ea257dc4aec0ad2610d8d5281ce478565d Updated travis install command.
      • 1b5167054907b94a7c8dda7f95871661bbf285a2 Expanded Python test versions.
      • 469ed83d11d62684e07798781014b4f2dde89b0d Added tox configuration for running tests across multiple Python versiosn. Fixed Python3 support.
      • acf095b78208edb59b5873662653e12773add3cc Fixed import to support Django>=1.9.
      • 1c84627980c0b77f8f9005fdbcc916ca33d0e4d1 Leadership note.
      • 13cd65e6e47fffe91a34f14b4030b14382de3963 Travis script fix
      • 12da9667deba432d8917129afab1daa86c20ec84 Full Python 2+3 support

    Is there a chance to get a new release tagged and uploaded to PyPI?

    Thanks in advance!

    opened by hartwork 1
  • Tag 668d11edbd62052cde1583be1e1d0512c930f16d as 0.3.6?

    Tag 668d11edbd62052cde1583be1e1d0512c930f16d as 0.3.6?

    Hi!

    Since I didn't find a Git tag for release 0.3.6 I tried to find a Git commit with a tree matching the 0.3.6 tarball on PyPI. Interestingly, there doesn't seem to be any exact match. 668d11edbd62052cde1583be1e1d0512c930f16d is close but it lacks two files that PyPI has:

    • socketio/exceptions.py
    • socketio/storage.py

    While socketio/storage.py seems to never have bin in Git at all, socketio/exceptions.py never was in that state (containing a single class SessionNotFound).

    Anyone got an idea about these two files? Should 668d11edbd62052cde1583be1e1d0512c930f16d still be tagged as 0.3.6?

    opened by hartwork 0
SocketIO 转发台,保持 botoy 能力和插件功能的同时,透传其接口,以此使用更灵活、生态更好的技术进行开发

bot_sio_transfer SocketIO 转发台,保持 botoy 能力和插件功能的同时,透传其接口,以此使用更灵活、生态更好的技术进行开发 Usage 请参考 botoy 文档接入本插件 Example 考虑一种图文混排场景,如何从复杂结构内快速获取第一张图片的 url ? ( 假设图片

OPQ Open Source Community 3 Oct 18, 2021
It's an extra broadcast driver for masonite. It adds support for socketio.

It's an extra broadcast driver for masonite. It adds support for socketio.

Yubaraj Shrestha 6 Feb 23, 2022
Basic Docker Compose template application with Flask, Celery, Redis, MySQL, SocketIO, Nginx and Gunicorn.

Nginx / Gunicorn / Flask ?? / Celery / SocketIO / MySQL / Redis / Docker ?? sample application Basic Docker Compose template application for orchestat

Alex Oarga 8 Aug 6, 2022
A server hosts a FastAPI application and multiple clients can be connected to it via SocketIO.

FastAPI_and_SocketIO A server hosts a FastAPI application and multiple clients can be connected to it via SocketIO. Executing server.py sets up the se

Ankit Rana 2 Mar 4, 2022
Requests + Gevent = <3

GRequests: Asynchronous Requests GRequests allows you to use Requests with Gevent to make asynchronous HTTP Requests easily. Note: You should probably

Spencer Phillip Young 4.2k Dec 30, 2022
Mr. Queue - A distributed worker task queue in Python using Redis & gevent

MRQ MRQ is a distributed task queue for python built on top of mongo, redis and gevent. Full documentation is available on readthedocs Why? MRQ is an

Pricing Assistant 871 Dec 25, 2022
Simple reproduction of connection leak with celery/django/gevent

Redis connection leak with celery/django/gevent Reproduces celery issue at https://github.com/celery/celery/issues/6819 using gevented django web serv

null 2 Apr 3, 2022
In this Github repository I will share my freqtrade files with you. I want to help people with this repository who don't know Freqtrade so much yet.

My Freqtrade stuff In this Github repository I will share my freqtrade files with you. I want to help people with this repository who don't know Freqt

Simon Kebekus 104 Dec 31, 2022
Prabashwara's Pm Bot repository. You can deploy and edit this repository.

Tᴇʟᴇɢʀᴀᴍ Pᴍ Bᴏᴛ | Prabashwara's PM Bot Unmaintained. The new repo of @Pm-Bot is private. (It is no longer based on this source code. The completely re

Rivibibu Prabshwara Ⓒ 2 Jul 5, 2022
Official repository for Spyder - The Scientific Python Development Environment

Copyright © 2009–2021 Spyder Project Contributors Some source files and icons may be under other authorship/licenses; see NOTICE.txt. Project status B

Spyder IDE 7.3k Dec 31, 2022
A jazzy skin for the Django Admin-Interface (official repository).

Django Grappelli A jazzy skin for the Django admin interface. Grappelli is a grid-based alternative/extension to the Django administration interface.

Patrick Kranzlmueller 3.4k Dec 31, 2022
Official project repository for the Setuptools build system

See the Installation Instructions in the Python Packaging User's Guide for instructions on installing, upgrading, and uninstalling Setuptools. Questio

Python Packaging Authority 1.9k Jan 8, 2023
Unknown Horizons official code repository

Unknown-Horizons based on Fifengine is no longer in development. We are porting it to Godot Engine. Please dont report any new bugs. Only bugfixes wil

Unknown Horizons 1.3k Dec 30, 2022
The official source code repository for the calibre ebook manager

calibre calibre is an e-book manager. It can view, convert, edit and catalog e-books in all of the major e-book formats. It can also talk to e-book re

Kovid Goyal 14.1k Dec 27, 2022
Official repository for Pyew.

pyew Pyew is a (command line) python tool to analyse malware. It does have support for hexadecimal viewing, disassembly (Intel 16, 32 and 64 bits), PE

Joxean 362 Nov 28, 2022
Official repository for "PAIR: Planning and Iterative Refinement in Pre-trained Transformers for Long Text Generation"

pair-emnlp2020 Official repository for the paper: Xinyu Hua and Lu Wang: PAIR: Planning and Iterative Refinement in Pre-trained Transformers for Long

Xinyu Hua 31 Oct 13, 2022
Official repository for Few-shot Image Generation via Cross-domain Correspondence (CVPR '21)

Few-shot Image Generation via Cross-domain Correspondence Utkarsh Ojha, Yijun Li, Jingwan Lu, Alexei A. Efros, Yong Jae Lee, Eli Shechtman, Richard Zh

Utkarsh Ojha 251 Dec 11, 2022
Official repository for Jia, Raghunathan, Göksel, and Liang, "Certified Robustness to Adversarial Word Substitutions" (EMNLP 2019)

Certified Robustness to Adversarial Word Substitutions This is the official GitHub repository for the following paper: Certified Robustness to Adversa

Robin Jia 38 Oct 16, 2022
Official repository for the ICLR 2021 paper Evaluating the Disentanglement of Deep Generative Models with Manifold Topology

Official repository for the ICLR 2021 paper Evaluating the Disentanglement of Deep Generative Models with Manifold Topology Sharon Zhou, Eric Zelikman

Stanford Machine Learning Group 34 Nov 16, 2022
The repository offers the official implementation of our paper in PyTorch.

Cloth Interactive Transformer (CIT) Cloth Interactive Transformer for Virtual Try-On Bin Ren1, Hao Tang1, Fanyang Meng2, Runwei Ding3, Ling Shao4, Phi

Bingoren 49 Dec 1, 2022