Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search not working #21

Open
ottodv opened this issue Mar 23, 2017 · 22 comments
Open

Search not working #21

ottodv opened this issue Mar 23, 2017 · 22 comments

Comments

@ottodv
Copy link

ottodv commented Mar 23, 2017

Search is not working for me, I keep getting the error below in the multichain-explorer log when doing a search. The error is repeated several times. I am running on Ubuntu.

127.0.0.1 - - [23/Mar/2017 21:31:06] "GET /search?q=13bbcc3c02b38f671cffe444c8bacf3f5d6f08a67b6694c4081af5d64d72e625 HTTP/1.1" 301 0
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run
    self.finish_response()
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response
    self.write(data)
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 204, in write
    assert type(data) is StringType,"write() argument must be string"
AssertionError: write() argument must be string
127.0.0.1 - - [23/Mar/2017 21:31:06] "GET /search?q=13bbcc3c02b38f671cffe444c8bacf3f5d6f08a67b6694c4081af5d64d72e625 HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 131, in handle
    handler.run(self.server.get_app())
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 92, in run
    self.close()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 33, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
@bitcartel
Copy link
Contributor

@ottodv What version of python are you running? 2.7.???

@ottodv
Copy link
Author

ottodv commented Mar 28, 2017

Python 2.7.12

@bitcartel
Copy link
Contributor

bitcartel commented Mar 28, 2017

This error only occurs on the search page?

@ottodv
Copy link
Author

ottodv commented Mar 29, 2017

Yes, that's the only situation in which I encounter this error.
BTW, I also did a new install from scratch on another VM, but using CentOS this time, to see if the error occurs there too.
The result is exactly the same error in the same situation (i.e. doing a search).
The Python version on that VM is 2.7.5

@gidgreen
Copy link
Contributor

This should now be fixed in the latest version of the Explorer - if so please close the issue.

@ottodv
Copy link
Author

ottodv commented Mar 29, 2017

I installed the lastest version from github as you suggested. Search still doesn't work, but in addition to the previous error, I got an additional error message in the log (on Ubuntu, strangely not on CentOS). It doesn't look very helpful, but I post it here just in case it might be to you.

AttributeError: 'NoneType' object has no attribute 'split'
myheader': [], 'title': ['MultiChain Explorer', ' ', '0.8pre'], 'dotdot': '', 'params': {'q': ['100']}, 'env': {'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'LC_ALL': 'en_US.UTF-8', 'wsgi.multiprocess': False, 'SERVER_PORT': '80', 'HTTP_REFERER': 'http://<REMOVED URL>/chains', 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x7f4ab654bbb0>, 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.12', 'SERVER_PROTOCOL': 'HTTP/1.1', 'wsgi.multithread': True, 'SCRIPT_NAME': '', 'wsgi.input': <socket._fileobject object at 0x7f4ab60428d0>, 'REQUEST_METHOD': 'GET', 'LOGNAME': 'node', 'PATH_INFO': '/search', 'HOME': '/home/node', 'QUERY_STRING': 'q=100', 'PATH': '/usr/bin:/bin:/home/node/bin:/usr/local/bin', 'REMOTE_ADDR': '<REMOVED IP>', '_': '/usr/bin/python', 'wsgi.version': (1, 0), 'LANG': 'en_US.UTF-8', 'SHELL': '/bin/sh', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0', 'SERVER_NAME': 'explore.localdomain', 'GATEWAY_INTERFACE': 'CGI/1.1', 'SHLVL': '2', 'OLDPWD': '/home/node', 'HTTP_X_COOKIESOK': 'I explicitly accept all cookies', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8,nl;q=0.7,fr;q=0.5,et;q=0.3,de;q=0.2', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7f4ab78f41e0>, 'wsgi.url_scheme': 'http', 'wsgi.run_once': False, 'PWD': '/home/node/multichain-explorer', 'CONTENT_TYPE': 'text/plain', 'CONTENT_LENGTH': '', 'HTTP_HOST': '<REMOVED IP>', 'HTTP_UPGRADE_INSECURE_REQUESTS': '1', 'REMOTE_HOST': '', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate'}}
----------------------------------------
Exception happened during processing of request from ('<REMOVED IP>', 58796)
----------------------------------------
{'status': '200 OK', 'body': [], 'template': u'\n<!DOCTYPE html>\n<html lang="en">\n<head>\n    <meta charset="utf-8">\n    <meta http-equiv="X-UA-Compatible" content="IE=edge">\n    <meta name="viewport" content="width=device-width, initial-scale=1">\n    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->\n\n    <title>%(title)s</title>\n\n    <!-- Bootstrap and Theme -->\n    <link href="%(dotdot)s%(STATIC_PATH)scss/bootstrap.min.css" rel="stylesheet">\n    <link href="%(dotdot)s%(STATIC_PATH)scss/bootstrap-theme.min.css" rel="stylesheet">\n\n    <!-- jQuery (necessary for Bootstrap\'s JavaScript plugins) -->\n    <script src="%(dotdot)s%(STATIC_PATH)sjs/jquery-1.11.3.min.js"></script>\n    <!-- Include all compiled plugins (below), or include individual files as needed -->\n    <script src="%(dotdot)s%(STATIC_PATH)sjs/bootstrap.min.js"></script>\n\n    %(myheader)s\n</head>\n<body>\n    <div class="container">\n\t<table><td>\n\t<a title="Back to home" href="%(dotdot)s%(HOMEPAGE)s"><img src="%(dotdot)s%(STATIC_PATH)slogo32.png" alt="MultiChain logo" /></a>\n\t</td><td style="padding-left: 10px;" valign="middle">\n\t<h1>%(h1)s<h1>\n\t</td></table>\n    %(body)s\n    <!--<p><a href="%(dotdot)sq">API</a> (machine-readable pages)</p>-->\n    <br><br>\n    <p style="font-size: smaller">\n        <span style="font-style: italic">\n            Powered by <a href="%(ABE_URL)s">%(APPNAME)s</a>\n        </span>\n        %(download)s\n    </p>\n    </div>\n</body>\n</html>\n', 'chain': None, 'start_response': <bound method ServerHandler.start_response of <wsgiref.simple_server.ServerHandler instance at 0x7f4ab5f56710>>, 'content_type': 'text/html; charset=utf-8', 'myheader': [], 'title': ['MultiChain Explorer', ' ', '0.8pre'], 'dotdot': '', 'params': {'q': ['100']}, 'env': {'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'LC_ALL': 'en_US.UTF-8', 'wsgi.multiprocess': False, 'SERVER_PORT': '80', 'HTTP_REFERER': 'http://<REMOVED URL>/chains', 'wsgi.file_wrapper': <class wsgiref.util.FileWrapper at 0x7f4ab654bbb0>, 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.7.12', 'SERVER_PROTOCOL': 'HTTP/1.1', 'wsgi.multithread': True, 'SCRIPT_NAME': '', 'wsgi.input': <socket._fileobject object at 0x7f4ab60428d0>, 'REQUEST_METHOD': '<REMOVED IP> - - [29/Mar/2017 18:13:32] "GET /search?q=100 HTTP/1.1" 301 0

@gidgreen
Copy link
Contributor

That's an error we should have fixed - did you rerun the python setup.py command from the README file?

@ottodv
Copy link
Author

ottodv commented Mar 29, 2017

Did now (python setup.py install), but still no dice. Even restarted the VMs. I am now back to seeing only the error I quoted in my opening post, on both the Ubuntu and CentOS severs.

@gidgreen
Copy link
Contributor

OK - thanks for the update. It fixed the search redirect problem we were seeing, but there's obviously a version/configuration issue here. We'll keep working on it.

@maxidev
Copy link

maxidev commented Apr 16, 2017

Same error here, search still does not work.

@reiven
Copy link

reiven commented May 15, 2017

ping

@gidgreen
Copy link
Contributor

If you're seeing this problem please post your Python version.

@reiven
Copy link

reiven commented May 16, 2017

I have the same error described by @ottodv (self.status.split(' ',1)[0], self.bytes_sent)

$ python --version
Python 2.7.13

Update: trying to run with python-3.5 i got this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
   File "/usr/local/lib/python3.5/runpy.py", line 153, in _get_module_details
    code = loader.get_code(mod_name)
  File "<frozen importlib._bootstrap_external>", line 775, in get_code
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/srv/multichain-explorer/Mce/abe.py", line 1206
    print "Exception:", e
                     ^
SyntaxError: Missing parentheses in call to 'print'

@maxidev
Copy link

maxidev commented May 16, 2017

python --version
Python 2.7.12

@maxidev
Copy link

maxidev commented May 16, 2017

Count me in if we have to test something on my box, I can post results, versions, etc.

@gidgreen
Copy link
Contributor

Thanks, so seems very specific to Python 2.7.12/13. We'll look into it and let you know if we need any more info.

@maxidev
Copy link

maxidev commented May 17, 2017

What version do you recommend? I will try to manually change Python version until we can fix it.

UPDATE: my traceback

Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 131, in handle
    handler.run(self.server.get_app())
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 92, in run
    self.close()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 33, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

@ottodv
Copy link
Author

ottodv commented May 18, 2017

I also tried it on CentOS with Python version 2.7.5. Same Error. See my earlier comment from March 29.

@maxidev
Copy link

maxidev commented May 20, 2017

We've managed to temporary solve this issue by making some small changes on Python libraries.
This are the changes.

/usr/lib/python2.7/wsgiref/simple_server.py

Class ServerHandler

class ServerHandler(SimpleHandler):

    server_software = software_version

    def close(self):
        try:
            # if self.status is not defined, pass hardcoded status
            status = "200"
            if self.status:
               status = self.status.split(' ', 1)[0]
            self.request_handler.log_request(
                status, self.bytes_sent
            )
        finally:
            SimpleHandler.close(self)

/usr/lib/python2.7/wsgiref/handles.py

Class BaseHandler

method "finish_response"

def finish_response(self):
        try:
            if not self.result_is_file() or not self.sendfile():
                for data in self.result:
                    # self.write(data)
                    # convert data to str
                    self.write(str(data)) 
                self.finish_content()
        finally:
            self.close()

method "client_is_modern"

def client_is_modern(self):
        """True if client can accept status and headers"""
        # check if self.environ is defined
        if not self.environ:
            return False
        return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'

/cc @gidgreen

@reiven
Copy link

reiven commented May 20, 2017

@maxidev maybe you can switch the fix to a PR?

@maxidev
Copy link

maxidev commented May 20, 2017

@reiven I can't because this was done on Python libraries instead of Multichain-explorer code.

@ssls18years
Copy link

ssls18years commented Oct 15, 2017

i found same errors. i try search by address, txid, blocknumber...,but only blocknumber is success, others will cause page crash.

i installed latest explore and 100009 multichain

after i modify simple_server.py & handles.py, search works correctly.

But, this is finally solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants