Issues With Python WSGI

Discussion in 'Linux Support: Debian, Ubuntu, SolusOS etc' started by devbydylan, Dec 15, 2017.

  1. devbydylan

    devbydylan New Member

    I have followed the guides to setup WSGI including this one.
    I'm currently using the hello world script and keep getting a 503 error.
    I'm running on Ubuntu 16.04, no special install of the OS with latest stable OpenLiteSpeed installed (1.4.28) and wsgi-lsapi 1.2
    Any help/guidance would be appreciated.

    This is my error.log

    Code:
    2017-12-15 12:28:21.510 [DEBUG] [*:8088] New connection from 24.129.75.36:1770.
    2017-12-15 12:28:21.510 [DEBUG] [*:8088] 0 connections accepted!
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] concurrent conn: 1
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] NtwkIOLink::handleEvents() events=1!
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] HttpSession::onReadEx(), state: 1!
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] readToHeaderBuf().
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] Read from client: 437
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] Read 437 bytes to header buffer.
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770] processHeader() returned 0, header state: 3.
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example] NtwkIOLink::suspendRead()...
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example] Find context with URI: [/], location: [/usr/local/lsws/Example/html/].
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example] Check Symbolic link for [/usr/local/lsws/Example/html/hw2.wsgi] is successful, access to target [/usr/local/lsws/Example/html/hw2.wsgi] is gr$
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example] Find handler [wsgiApp] for [.wsgi].
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example] processContextPath() returned 0.
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example] Run lsapi processor.
    2017-12-15 12:28:21.510 [DEBUG] [uds://tmp/lshttpd/lswsgi.sock] request [24.129.75.36:1770#Example:lsapi] is assigned with connection!
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] reconnect()
    2017-12-15 12:28:21.510 [DEBUG] [wsgiApp] add child process pid: 9482
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onWrite()
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request header is done
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::continueRead()
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request body done!
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::suspendWrite()
    2017-12-15 12:28:21.510 [DEBUG] [*:8088] 1 connections accepted!
    2017-12-15 12:28:21.526 [DEBUG] EdStream::handleEvent(), fd: 25, event: 25
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onRead()
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] LsapiConn::doRead()
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] Process packet header -1 bytes
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] Connection to [uds://tmp/lshttpd/lswsgi.sock] on request #1, confirmed 0, error: Connection reset by peer!
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] close()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] reconnect()
    2017-12-15 12:28:21.527 [DEBUG] [wsgiApp] add child process pid: 9483
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onWrite()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request header is done
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::continueRead()
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request body done!
    2017-12-15 12:28:21.510 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::suspendWrite()
    2017-12-15 12:28:21.510 [DEBUG] [*:8088] 1 connections accepted!
    2017-12-15 12:28:21.526 [DEBUG] EdStream::handleEvent(), fd: 25, event: 25
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onRead()
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] LsapiConn::doRead()
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] Process packet header -1 bytes
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] Connection to [uds://tmp/lshttpd/lswsgi.sock] on request #1, confirmed 0, error: Connection reset by peer!
    2017-12-15 12:28:21.526 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] close()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] reconnect()
    2017-12-15 12:28:21.527 [DEBUG] [wsgiApp] add child process pid: 9483
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onWrite()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request header is done
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::continueRead()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request body done!
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::suspendWrite()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] close()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] HttpExtConnector::tryRecover()...
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Trying to recover from connection problem, attempt: #2!
    2017-12-15 12:28:21.527 [DEBUG] [uds://tmp/lshttpd/lswsgi.sock] request [24.129.75.36:1770#Example:lsapi] is assigned with connection!
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] reconnect()
    2017-12-15 12:28:21.527 [DEBUG] [wsgiApp] add child process pid: 9484
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onWrite()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request header is done
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::continueRead()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request body done!
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::suspendWrite()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onError()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onRead()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] LsapiConn::doRead()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Process packet header 0 bytes
    2017-12-15 12:28:21.540 [DEBUG] EdStream::handleEvent(), fd: 25, event: 25
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onRead()
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] LsapiConn::doRead()
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] Process packet header -1 bytes
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] Connection to [uds://tmp/lshttpd/lswsgi.sock] on request #1, confirmed 0, error: Connection reset by peer!
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] close()
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] reconnect()
    2017-12-15 12:28:21.541 [DEBUG] [wsgiApp] add child process pid: 9486
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onWrite()
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request header is done
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::continueRead()
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request body done!
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::suspendWrite()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onError()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onRead()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] LsapiConn::doRead()
    2017-12-15 12:28:21.527 [DEBUG] [24.129.75.36:1770#Example:lsapi] Process packet header 0 bytes
    2017-12-15 12:28:21.540 [DEBUG] EdStream::handleEvent(), fd: 25, event: 25
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onRead()
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] LsapiConn::doRead()
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] Process packet header -1 bytes
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] Connection to [uds://tmp/lshttpd/lswsgi.sock] on request #1, confirmed 0, error: Connection reset by peer!
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] close()
    2017-12-15 12:28:21.540 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] reconnect()
    2017-12-15 12:28:21.541 [DEBUG] [wsgiApp] add child process pid: 9486
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::onWrite()
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request header is done
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::continueRead()
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Request body done!
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] ExtConn::suspendWrite()
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] [ExtConn] close()
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] HttpExtConnector::tryRecover()...
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] NtwkIOLink::continueWrite()...
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Write resumed!
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] NtwkIOLink::handleEvents() events=4!
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] HttpExtConnector::cleanUp() ...
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Abort request...
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Release ExtProcessor!
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] NtwkIOLink::suspendWrite()...
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] Write suspended
    2017-12-15 12:28:21.541 [DEBUG] [24.129.75.36:1770#Example:lsapi] HttpSession::sendHttpError(), code = '503 Service Unavailable
    '.
     
  2. lskagan

    lskagan Administrator

    Is it possible to get the content of your hello world file. Also can you check the stderr.log to see if there is any information in that file?
     
    devbydylan likes this.
  3. devbydylan

    devbydylan New Member

    Thanks for the prompt response

    This is my hello world,
    Code:
    def application(environ, start_response):
            start_response('200 OK', [('Content-Type', 'text/plain')])
            return ['Hello World!\n']


    This is the contents of my stderr.log, although these errors do not stem from running the code and were propogated sometime beforehand and I'm not sure when.
    Code:
    Failed to open temp file for swapping: Permission denied
    Failed to open temp file for swapping: Permission denied
    Failed to open temp file for swapping: Permission denied
    Failed to open temp file for swapping: Permission denied
     
  4. devbydylan

    devbydylan New Member

    This is my LiteSpeed SAPI App configuration
    Code:
    Name: wsgiApp
    Address: uds://tmp/lshttpd/lswsgi.sock
    Max Connections: 50
    Initial Request Timeout: 60
    Retry Timeout: 15
    Persistent Connection: Yes
    Connection Keep-Alive Timeout: -1
    Response Buffering: No
    Auto Start: Yes
    Command: /usr/local/lsws/fcgi-bin/lswsgi
    Back Log: 100
    Instances: 1
    Run On Start Up: Yes
    Max Idle Time: -1
    Priority: 0
    Memory Soft: 2044M
    Memory Hard: 2048M
    Process Soft Limit: 400
    Process Hard Limit: 500
     
  5. Tishu

    Tishu Member

    Hello,

    What are the permissions and owner for /tmp/lshttpd/swap
     
  6. devbydylan

    devbydylan New Member

    ls -l provides these current permissions I have under the swap directory

    Code:
    drwx------ 9 nobody nogroup 4096 Dec 18 11:03 swap
     
  7. Tishu

    Tishu Member

    Hello again,

    If OLS is running under nobody:nobody, please chown /tmp/lshttpd with that. Restart OLS and check again.
     
  8. devbydylan

    devbydylan New Member

    Thanks for the feedback,

    Under my server configuration it says-
    Code:
    Running As: user(nobody) : group(nogroup)
    Should I assume my configuration is correct and there is another issue or could this be incorrect?
     
  9. lskagan

    lskagan Administrator

Share This Page