Websockets
- 2013 - New way for javascript to open a tcp connection back to the server for data transfer.
- Here is some notes as I struggled to get the first examples to work.
- Errors in apache log files
Exception: ('PythonOption mod_pywebsocket.handler_root is not defined', 3)
AttributeError: object has no attribute "APLOG_DEBUG"
- Cause was that i had to have the websocket config above the default virtual server in my apache2 config file.
##PES 2013 pywebsocket <IfModule python_module> PythonPath "sys.path+['/mod_pywebsocket']" PythonOption mod_pywebsocket.handler_root /var/www PythonOption mod_pywebsocket.handler_scan /var/www/ws #PythonOption mod_pywebsocket.allow_draft75 On <Location /ws> PythonHeaderParserHandler mod_pywebsocket.headerparserhandler </Location> </IfModule> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel debug CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
- Errors in apache log files
- To test
copy file echo_wsh.py into /var/www/ws
open webpage to test file:///usr/share/doc/python-mod-pywebsocket/examples/console.html in browser
test by entering in webpage abe the url ws://localhost/ws/echo
on web page in display window you should see message Connect ws://localhost/ws/echo
- Another problem was with /var/www/ws/websockify_wsh.py
Found in Apache2 log websockify: ws_protocol = 'binary' (['binary', 'base64'])
- It was picking binary for socket and noVNC only supports base64.
- Solution, just before it picked the first option, i check for base64 and rather select it.
- Another problem, connecting with vnc.html, found in apache2 log.
mod_pywebsocket: websockify: connection denied: 'NoneType' object has no attribute 'split'
...