sgowtham441 / pywebsocket

Automatically exported from code.google.com/p/pywebsocket
0 stars 0 forks source link

Mod_python return Assertion Error with mod_pywebsocket.headerparserhandler #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Following the instruction to install mod_pywebsocket 
2. mod_python is installed and running fine
3. mod_pywebsocket installation seems ok
4. apache is configure with this

AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
PythonPath "sys.path+['/Library/Python/2.7/site-packages/mod_pywebsocket']"
PythonOption mod_pywebsocket.handler_root 
/Library/WebServer/python/websock_handlers
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler

5. apache is restarted

What is the expected output? What do you see instead?

When i try to load any page on the server i get this instead

MOD_PYTHON ERROR

ProcessId:      4000
Interpreter:    'dohko.gim.pasteur.fr'

ServerName:     'dohko.gim.pasteur.fr'
DocumentRoot:   '/Library/WebServer/Documents'

URI:            '/excalibur/excalibur.html'
Location:       None
Directory:      None
Filename:       '/Library/WebServer/Documents/excalibur/excalibur.html'
PathInfo:       ''

Phase:          'PythonHeaderParserHandler'
Handler:        'mod_pywebsocket.headerparserhandler'

Traceback (most recent call last):

  File "/Library/Python/2.7/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/Library/Python/2.7/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/Library/Python/2.7/site-packages/mod_python/importer.py", line 1155, in _execute_target
    assert (type(result) == types.IntType), _result_warning % type(result)

AssertionError: Handler has returned result or raised SERVER_RETURN
exception with argument having non integer type. Type of value returned
was <type 'NoneType'>, whereas expected <type 'int'>.

What version of the product are you using? On what operating system?
I am on Mac OS 10.7
I use apache 2, python 2.7, mod_python 3.3.1 and mod_pywebsocket 0.6b6

I have the same result on Ubuntu 10.10 with python 2.6, mod_python 3.3.1 and 
mod_pywebsocket 0.6b6

Original issue reported on code.google.com by christop...@gmail.com on 20 Oct 2011 at 2:50

GoogleCodeExporter commented 9 years ago
I realized i didn't use the very last version of mod_pywebsocket because i 
downloaded directly instead of using svn.
using ssn, to get the last version of the files, i reinstalled mod_pywebsocket.
I have no longer the mod_python error but instead a 400 bad request response 
from the server for every page i try to load.
Complete error is the following
**************

Bad Request

Your browser sent a request that this server could not understand.

***********

But On the other hand, websockets seem to work now. I tried 
var ws= new WebSocket("ws://localhost/echo");
and
ws.send('click') and the response was true for the last command.

So now I just have to understand why server respond with an error for every 
other request

Someone to help me ? I would really like to make this work

Thanks

Original comment by christop...@gmail.com on 20 Oct 2011 at 3:51

GoogleCodeExporter commented 9 years ago
It seems to be the ame issue as 
https://groups.google.com/forum/#!topic/pywebsocket/1tjOny5I3Pw

Old implementation always fallback to apache when pywebsocket could not handle 
client request correctly.
But, the newest spec requires 400 bad request for wrong opening handshake.
My recent change to support 400 broke compatibility around it.

I submit new change to fix this issue.
Now, pywebsocket checks handler existence then sends http response with 400.
If handler doesn't exist, pywebsocket will fallback to apache as you expect.

Could you try r583?

Original comment by toyoshim@chromium.org on 21 Oct 2011 at 8:56

GoogleCodeExporter commented 9 years ago
Works like a charm, thank you very much.
I can play with websockets now

Original comment by christop...@gmail.com on 21 Oct 2011 at 9:20

GoogleCodeExporter commented 9 years ago

Original comment by toyoshim@chromium.org on 25 Oct 2011 at 6:00