gevent-socketio icon indicating copy to clipboard operation
gevent-socketio copied to clipboard

Server not able to get address raising no attribute 'cfg_addr'

Open shuoli84 opened this issue 10 years ago • 7 comments

My setup:

Gunicorn + gevent_socketio + django

Started the server by:

gunicorn --env DJANGO_SETTINGS_MODULE=linbang.settings -c gunicorn_config.py --error-logfile -  linbang.wsgi:application

In gunicorn_config.py:

bind = '0.0.0.0:8000'
max_requests = 10000
worker_class = 'socketio.sgunicorn.GeventSocketIOWorker'
workers = 5

def post_fork(server, worker): import pymysql pymysql.install_as_MySQLdb()

 [2014-08-29 11:19:13 +0800] [79204] [ERROR] Exception in worker process:
  Traceback (most recent call last):
    File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 193, in init_process
    super(GeventWorker, self).init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
    self.run()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/sgunicorn.py", line 80, in run
    **ssl_args
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/server.py", line 72, in __init__
    address = args[0].cfg_addr[0]
AttributeError: 'socket' object has no attribute 'cfg_addr'
Traceback (most recent call last):
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 193, in init_process
    super(GeventWorker, self).init_process()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
    self.run()
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/sgunicorn.py", line 80, in run
    **ssl_args
  File "/Users/lishuo/envs/linbang/lib/python2.7/site-packages/socketio/server.py", line 72, in __init__
    address = args[0].cfg_addr[0]
AttributeError: 'socket' object has no attribute 'cfg_addr'

shuoli84 avatar Aug 29 '14 04:08 shuoli84

I'm having the same issue when stress testing simple test app.

AttributeError: 'socket' object has no attribute 'cfg_addr'

@shuoli84 I see that you use workers = 5 in your config file. Does it work without problems ? I was having errors when workers was set to > 1, despite the fact that I was using websocket transport (so this wasn't issue of long-polling and different processes for each request).

mateuszf avatar Oct 28 '14 17:10 mateuszf

I am having the same issue.

Jakobovski avatar Mar 17 '15 19:03 Jakobovski

Save the following snippet as geventworker.py

from socketio.sgunicorn import GeventSocketIOWorker

class MyGeventSocketIOWorker(GeventSocketIOWorker):
    policy_server = False

and launch your app with

 gunicorn --worker-class geventworker.MyGeventSocketIOWorker wsgy:app

ant9000 avatar Mar 30 '15 10:03 ant9000

as noted here, using earlier gunicorn versions may work for you.

pip uninstall gunicorn pip install gunicorn==18.0

jaredmcqueen avatar Apr 03 '15 12:04 jaredmcqueen

I just committed a fix, which will make it work with newer version of gunicorn. The merge is pending. ant9000 workaround will help but better solution is to adapt to gunicorn changes.

jares777 avatar May 23 '15 03:05 jares777

Merge will stay pending forever as this project is missing a maintainer.

BTW, I can confirm that the workaround of @ant9000 works fine. Alternatively, you can also set the environment variable POLICY_SERVER to false.

arnuschky avatar May 23 '15 08:05 arnuschky

Cool. I will stay with my forked branch then :)

jares777 avatar May 23 '15 16:05 jares777