ws4py with CherryPy/cpstats?

21 views
Skip to first unread message

Israel Brewster

unread,
Oct 28, 2015, 12:21:37 PM10/28/15
to ws4py
I don't know if this is a CherryPy issue or a ws4py issue, so I'm asking in both places. Please forgive me if that is considered bad form. It it possible to use ws4py in conjunction with the capstans 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
  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.
Reply all
Reply to author
Forward
0 new messages