Worked on Ubuntu fails on RHEL6. Error: Handler returned a non-integer type.

205 views
Skip to first unread message

Kevin Cole

unread,
Oct 19, 2011, 12:36:19 PM10/19/11
to pywebsocket
Hi,

I had a simple demo running under Ubuntu which worked fine in August.  I had to move to RHEL in October. I have a file /etc/httpd/conf.d/pywebsocket.conf.  Uncommenting the only two lines in it:

| PythonOption mod_pywebsocket.handler_root /usr/local/lib/websock_handlers
| PythonHeaderParserHandler mod_pywebsocket.headerparserhandler

causes ALL pages on the website to fail. (Most of the other pages are completely static.)

It's probably some SElinux thing, or perhaps some change in the SVN repository.  I'm hoping the problem is obvious to someone on this list.

Here's a trimmed error log:

[notice] caught SIGTERM, shutting down
[notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[notice] Digest: generating secret for digest authentication ...
[notice] Digest: done
[error]  python_init: Python version mismatch, expected '2.6.2', found '2.6.6'.
[error]  python_init: Python executable found '/usr/bin/python'.
[error]  python_init: Python path being used '/usr/lib64/python26.zip:/usr/lib64/python2.6/
                                             :/usr/lib64/python2.6/plat-linux2:/usr/lib64/python2.6/lib-tk
                                             :/usr/lib64/python2.6/lib-old:/usr/lib64/python2.6/lib-dynload'.
[notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[notice] mod_python: using mutex_directory /tmp
[warn]   mod_wsgi: Compiled for Python/2.6.2.
[warn]   mod_wsgi: Runtime using Python/2.6.6.
[notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 mod_python/3.3.1 Python/2.6.6 mod_wsgi/3.2 configured
         -- resuming normal operations
[error]  mod_python (pid=30479, interpreter='[IP octet]', phase='PythonHeaderParserHandler',
                     handler='mod_pywebsocket.headerparserhandler'): Application error
[error]  ServerName: '[IP octet]'
[error]  DocumentRoot: '/var/www/html'
[error]  URI: '/~.../pywebsocket/progress.php'
[error]  Location: None
[error]  Directory: None
[error]  Filename: '/home/.../public_html/pywebsocket/progress.php'
[error]  PathInfo: ''
[error]  Traceback (most recent call last):
[error]    File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
              line 1540, in HandlerDispatch
              default=default_handler, arg=req, silent=hlist.silent)
[error]    File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
              line 1232, in _process_target
              result = _execute_target(config, req, object, arg)
[error]    File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
              line 1158, in _execute_target
              assert (type(result) == types.IntType), _result_warning % type(result)
[error]  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'>.
/usr/lib64/python2.6/site-packages/mod_python/importer.py:1549:
DeprecationWarning: catching of string exceptions is deprecated
  except apache.PROG_TRACEBACK, traceblock:
[notice] caught SIGTERM, shutting down


Kevin Cole

unread,
Oct 19, 2011, 1:51:49 PM10/19/11
to pywebsocket
Well... It's not an SElinux problem.  Setting enforcement to permissive got me nowhere.

Kevin Cole

unread,
Oct 19, 2011, 3:45:57 PM10/19/11
to pywebsocket
Changing the LogLevel to "debug" netted the following -- slightly edited -- which still doesn't help me. The page in the log below, howto.php, is a "mostly static" page.  The PHP just adds a stock header and footer to all my pages.  It doesn't contain any JavaScript.
__________________________________

[debug] _apachemodule.c(65): Opening handshake resource: '/~.../pywebsocket/howto.php'
[debug] _apachemodule.c(65): Opening handshake request headers: {'Accept-Language': 'en-us,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'DNT': '1', 'Connection': 'keep-alive', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Host': 'my.site.hostname', 'Cookie': 'useless nonsense', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache'}
[info] Trying IETF HyBi latest protocol
[info] Failed to complete opening handshake as IETF HyBi latest protocol: HandshakeException('Header Upgrade is not defined',)
[info] Trying IETF HyBi 00 protocol
[info] Failed to complete opening handshake as IETF HyBi 00 protocol: HandshakeException('Header Upgrade is not defined',)
[info] Trying IETF Hixie 75 protocol
[info] Failed to complete opening handshake as IETF Hixie 75 protocol: HandshakeException('Header Upgrade is not defined',)
[info] [client 134.231.51.2] mod_pywebsocket: Failed to complete opening handshake for all available protocols
[info] mod_wsgi (pid=29960): Destroying interpreters.
[info] mod_wsgi (pid=29960): Cleanup interpreter ''.
...

Takeshi Yoshino

unread,
Oct 19, 2011, 11:24:28 PM10/19/11
to pyweb...@googlegroups.com
Hi,

Which version are you using?

We've recently made a change which might break some use case. Now headerparserhandler doesn't fall back to HTTP. For now please wrap PythonHeaderParserHandler with Location or Directory directive to get only requests to specific path handled by pywebsocket, and serve normal HTTP by Apache.

We're thinking if we revert it or not. Feel free to give us comments.

Kevin Cole

unread,
Oct 20, 2011, 1:31:13 PM10/20/11
to pyweb...@googlegroups.com
On Wed, Oct 19, 2011 at 23:24, Takeshi Yoshino <tyos...@chromium.org> wrote:

> Hi,
>
> Which version are you using?

When I sent the previous messages, I was using:

r571 | tyos...@chromium.org | 2011-10-18 10:03:09 -0400 (Tue, 18 Oct 2011)

I just upgraded to:

r576 | toyo...@chromium.org | 2011-10-20 04:03:43 -0400 (Thu, 20 Oct 2011)

> We've recently made a change which might break some use case.
> Now headerparserhandler doesn't fall back to HTTP. For now
> please wrap PythonHeaderParserHandler with Location or Directory
> directive to get only requests to specific path handled by pywebsocket,
> and serve normal HTTP by Apache.

I'll try that and report back.

> We're thinking if we revert it or not. Feel free to give us comments.

What's the advantage of the recent change? I'm guessing it's a
security concern? Since I had it working before, my uneducated
instinct is to say "revert" without really knowing why the change was
made in the first place. I suppose I need to read more. ;-)

Kevin Cole

unread,
Oct 20, 2011, 5:13:32 PM10/20/11
to pyweb...@googlegroups.com
I've restricted to a single directory. So, now it's not blowing the
whole site away. But with the latest svn update (r576), I'm still
getting errors, which I've attempted to edit and line-wrap for sanity:

| [error] mod_python (pid=32229, interpreter='Host IP octet',


|         phase='PythonHeaderParserHandler',
|         handler='mod_pywebsocket.headerparserhandler'):
|         Application error

| [error] ServerName: 'Host IP octet'


| [error] DocumentRoot: '/var/www/html'
| [error] URI: '/~.../pywebsocket/progress.php'
| [error] Location: None

| [error] Directory: '/home/.../public_htmll/pywebsocket/'


| [error] Filename: '/home/.../public_html/pywebsocket/progress.php'
| [error] PathInfo: ''
| [error] Traceback (most recent call last):
| [error]   File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
|             line 1540, in HandlerDispatch
|             default=default_handler, arg=req,
|             silent=hlist.silent)
| [error]   File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",

|             line 1205, in _process_target
|             module = import_module(module_name, path=path)
| [error]   File "/usr/lib64/python2.6/site-packages/mod_python/importer.py",
|             line 307, in import_module
|             return __import__(module_name, {}, {}, ['*'])
| [error]   File
"/usr/lib/python2.6/site-packages/mod_pywebsocket/headerparserhandler.py",
|             line 162, in <module>
|             _dispatcher = _create_dispatcher()
| [error]   File
"/usr/lib/python2.6/site-packages/mod_pywebsocket/headerparserhandler.py",
|             line 143, in _create_dispatcher
|             apache.APLOG_ERR)
| [error] Exception: ('PythonOption mod_pywebsocket.handler_root
|                      is not defined', 3)

Takeshi Yoshino

unread,
Oct 20, 2011, 10:08:04 PM10/20/11
to pyweb...@googlegroups.com
Please restrict only PythonHeaderParserHandler. pywebsocket checks only PythonOption in the server context, so you need to put it outside Location/Directory/etc.

But we'll make a change that is a kind of revert of this behavior soon. Sorry for inconvenience. Please wait a bit. Thanks for comments.

Kevin Cole

unread,
Oct 21, 2011, 1:15:04 PM10/21/11
to pyweb...@googlegroups.com
On Thu, Oct 20, 2011 at 22:08, Takeshi Yoshino <tyos...@chromium.org> wrote:
> Please restrict only PythonHeaderParserHandler. pywebsocket checks only
> PythonOption in the server context, so you need to put it outside
> Location/Directory/etc.
> But we'll make a change that is a kind of revert of this behavior soon.
> Sorry for inconvenience. Please wait a bit. Thanks for comments.

Thanks.

Better, but not fixed yet. At least now it sometimes displays the page
although not the animation:

http://research.gallaudet.edu/~kjcole/pywebsocket/progress.php

If I refresh the page sometimes the browser says:

| Bad Request
|
| Your browser sent a request that this server could not understand.
| Apache/2.2.15 (Red Hat) Server at research.gallaudet.edu Port 80

But I'm guessing that it's now going to be solvable with a bit of
re-reading the documentation.

My rough documentation w/ source code (which still shows the old
Apache config, but will soon your changes) is at:

http://research.gallaudet.edu/~kjcole/pywebsocket/howto.php

Takashi Toyoshima

unread,
Oct 22, 2011, 10:24:53 AM10/22/11
to pyweb...@googlegroups.com
Hi Kevin,

I'm sorry for your inconvenience.

I checked your site.
ws://research.gallaudet.edu/progress seems to return 404 status.
So, I guess your configuration is still wrong.

Anyway, I fixed this compatibility issue.
http://code.google.com/p/pywebsocket/source/detail?r=583
I think this revision could work fine with your original configuration.

I'll push version 0.7 of pywebsocket at early next week.
It will include this fix and be fully compliant to latest hybi-17.

Thanks

Kevin Cole

unread,
Oct 27, 2011, 8:17:12 PM10/27/11
to pyweb...@googlegroups.com
Making slow "progress" debugging progress.php and progress.js

I added some debugging code, and changed WebSocket to MozWebSocket.
The current problem appears to be that

> PythonOption mod_pywebsocket.handler_root /usr/local/lib64/websock_handlers

is being ignored. I have verified that it is in the global section.
Instead, it looks in the webserver document root

The Javascript lines:

> document.getElementById("debug").innerHTML = "Connecting...";
> socket = new MozWebSocket("ws://research.gallaudet.edu/progress");
> document.getElementById("debug").innerHTML = "Connected...";

show the text change from "Connecting..." to "Connected..." in the web
page, but Apache puts an entry in /var/log/httpd/error_log

> [error] File does not exist: /var/www/html/progress

Takashi Toyoshima

unread,
Oct 27, 2011, 9:35:12 PM10/27/11
to pyweb...@googlegroups.com
Hi Kevin,

I posted pywebsocket-0.7 yesterday.
It includes the improvements Takeshi said, and also includes sample
configuration file for apache.
http://code.google.com/p/pywebsocket/source/browse/tags/pywebsocket-0.7/src/example/pywebsocket.conf

Anyway...

>> document.getElementById("debug").innerHTML = "Connecting...";
>> socket = new MozWebSocket("ws://research.gallaudet.edu/progress");
>> document.getElementById("debug").innerHTML = "Connected...";

You should catch onopen event by handler. At the point you show 'Connected...',
WebSocket might be going to perform opening handshake, but not connected.

console.html in our example could be good sample how to use WebSocket.
http://code.google.com/p/pywebsocket/source/browse/tags/pywebsocket-0.7/src/example/console.html

Thanks,

Kevin Cole

unread,
Oct 28, 2011, 4:35:20 PM10/28/11
to pyweb...@googlegroups.com
It's working again. Thanks. I had to move all *.php, *.js and *.py
under /var/www/html/ to make it work.  (That wasn't the case under
Ubuntu when I tried it a few months ago. My .py files lived in a
/usr/local/ directory and the .js and .php lived in a user public_html
directory.)

So, now mod_pywebsocket.handler_root has to refer to a directory
under Apache's DocumentRoot? Or am I misunderstanding what went wrong
and why it's fixed now for me?

Takeshi Yoshino

unread,
Oct 31, 2011, 12:53:35 AM10/31/11
to pyweb...@googlegroups.com
You can use your home dir. Please just specify the directory where you placed WebSocket handler files by mod_pywebsocket.handler_root PythonOption. pywebsocket.conf is just an example.

Reply all
Reply to author
Forward
0 new messages