CherryPy cpstats and ws4py

Israel Brewster israel at ravnalaska.net
Tue Nov 3 12:05:19 EST 2015


I posted this to the CherryPy and ws4py mailing lists, but in the week since I did that I've only gotten two or three views on each list, and no responses, so as a last-ditch effort I thought I'd post here. Maybe someone with more general python knowledge than me can figure out the traceback and from there a solution.

Is it possible to use ws4py in conjunction with the cpstats CherryPy tool? I have a CherryPy (3.8.0) web app that uses web sockets via ws4py. Tested and working. I am now trying to get a little more visibility into the functioning of the server, so to that end I enabled the cpstats tool by adding the following line to my '/' configuration:

tools.cpstats.on=True

Unfortunately, as soon as I do that, attempts to connect a web socket start failing with the following traceback:

[28/Oct/2015:08:18:48]  
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/CherryPy-3.8.0-py2.7.egg/cherrypy/_cprequest.py", line 104, in run
    hook()
  File "/Library/Python/2.7/site-packages/CherryPy-3.8.0-py2.7.egg/cherrypy/_cprequest.py", line 63, in __call__
    return self.callback(**self.kwargs)
  File "build/bdist.macosx-10.10-intel/egg/ws4py/server/cherrypyserver.py", line 200, in upgrade
    ws_conn = get_connection(request.rfile.rfile)
  File "build/bdist.macosx-10.10-intel/egg/ws4py/compat.py", line 43, in get_connection
    return fileobj._sock
AttributeError: 'KnownLengthRFile' object has no attribute '_sock'
[28/Oct/2015:08:18:48] HTTP 
Request Headers:
  PRAGMA: no-cache
  COOKIE: autoTabEnabled=true; fleetStatusFilterCompany=7H; fleetStatusFilterLocation=ALL; fleetStatusRefreshInterval=5; inputNumLegs=5; session_id=5c8303896aff419c175c79dfadbfdc9d75e6c45a
  UPGRADE: websocket
  HOST: flbubble.ravnalaska.net:8088
  ORIGIN: http://flbubble.ravnalaska.net
  CONNECTION: Upgrade
  CACHE-CONTROL: no-cache
  SEC-WEBSOCKET-VERSION: 13
  SEC-WEBSOCKET-EXTENSIONS: x-webkit-deflate-frame
  USER-AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7
  SEC-WEBSOCKET-KEY: Szh6Uoe+WzqKR1DgW8JcXA==
  Remote-Addr: 10.9.1.59
[28/Oct/2015:08:18:48] HTTP 
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/CherryPy-3.8.0-py2.7.egg/cherrypy/_cprequest.py", line 661, in respond
    self.hooks.run('before_request_body')
  File "/Library/Python/2.7/site-packages/CherryPy-3.8.0-py2.7.egg/cherrypy/_cprequest.py", line 114, in run
    raise exc
AttributeError: 'KnownLengthRFile' object has no attribute '_sock'

Disable tools.cpstats.on, and the sockets start working again. Is there some way I can fix this so I can use sockets as well as gather stats from my application? Thanks.

-----------------------------------------------
Israel Brewster
Systems Analyst II
Ravn Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7293
-----------------------------------------------




More information about the Python-list mailing list