Skip to content
New issue

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

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

Already on GitHub? # to your account

AssertionError: Connection is a "hop-by-hop" header; it cannot be used by a WSGI application (see PEP 3333) #5

Open
GerbenKwakkel opened this issue Feb 15, 2016 · 5 comments

Comments

@GerbenKwakkel
Copy link

After logon with Google Authenticator, i proxy'ed to another internal server i got the following error:

AssertionError: Connection is a "hop-by-hop" header; it cannot be used by a WSGI application (see PEP 3333)

This is the setting in my config:

[app:proxy]
use = egg:factored#simpleproxy
server = 10.0.12.21
port = 80
urlscheme = http

10.0.12.22:8000 is my Factored machine.

Anyone knows what i doing wrong?

@vangheem
Copy link
Contributor

Looks like WSGI doesn't support it: https://www.python.org/dev/peps/pep-0333/

Wonder if there is a way around it since it is just proxying.

@GerbenKwakkel
Copy link
Author

Thanks for the reaction.

But how can i forward from Factored authentication to my internal web application? What i try, in all situations i get the hop-by-hop header error.

@vangheem
Copy link
Contributor

Yes, I'm not sure. I've never seen this and I don't know what your backend server looks like.

You could try integrating with a proxy server instead: https://factored.readthedocs.org/en/latest/webserverplugins.html

Otherwise, maybe try disabling the hop-by-hop on your webserver?

What is the full traceback of the factored error? Can you try commenting out those lines of code that force the AssertionError and see how it behaves ignoring the headers?

@GerbenKwakkel
Copy link
Author

root@FACTORED:~/factored# ./bin/pserve develop.ini
Starting server in PID 21905.
serving on http://0.0.0.0:8000
ERROR:waitress:Exception when serving /
Traceback (most recent call last):
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 337, in service
    task.service()
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 392, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/root/factored/factored/app.py", line 169, in __call__
    return SMFilter(wrapped_app)(environ, start_response)
  File "/root/factored/factored/sm.py", line 87, in __call__
    result = self.application(environ, start_response)
  File "/root/factored/factored/app.py", line 167, in wrapped_app
    return self.app(environ2, start_response2)
  File "/root/factored/factored/app.py", line 187, in __call__
    return proxy_exact_request(environ, start_response)
  File "/root/factored/eggs/WSGIProxy-0.2.2-py2.7.egg/wsgiproxy/exactproxy.py", line 100, in proxy_exact_request
    start_response(status, headers_out)
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 384, in start_response
    'a WSGI application (see PEP 3333)' % k)
AssertionError: Connection is a "hop-by-hop" header; it cannot be used by a WSGI application (see PEP 3333)
ERROR:waitress:Exception when serving /favicon.ico
Traceback (most recent call last):
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 337, in service
    task.service()
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 392, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/root/factored/factored/app.py", line 169, in __call__
    return SMFilter(wrapped_app)(environ, start_response)
  File "/root/factored/factored/sm.py", line 87, in __call__
    result = self.application(environ, start_response)
  File "/root/factored/factored/app.py", line 167, in wrapped_app
    return self.app(environ2, start_response2)
  File "/root/factored/factored/app.py", line 187, in __call__
    return proxy_exact_request(environ, start_response)
  File "/root/factored/eggs/WSGIProxy-0.2.2-py2.7.egg/wsgiproxy/exactproxy.py", line 100, in proxy_exact_request
    start_response(status, headers_out)
  File "/root/factored/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 384, in start_response
    'a WSGI application (see PEP 3333)' % k)
AssertionError: Connection is a "hop-by-hop" header; it cannot be used by a WSGI application (see PEP 3333)

This is the output, when i forward to a nginx reverse proxy with the following setting:

server {
    listen  80;
    server_name 2fa.domain.told;
    include proxy_params;

    # paths to protect
    location ~ ^/.* {
        proxy_pass http://127.0.0.1:8000;
    }

     location / {
        proxy_pass http://10.0.12.21;
    }
}

server {
    listen 80;
    include proxy_params;
    location / {
        proxy_pass http://10.0.12.21;
    }
}

Then i received the same error...
When i used the develop-noproxy.ini file, after authenticate i came back at the login screen from Factored.

@rayanfer32
Copy link

Use gunicorn server

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

No branches or pull requests

3 participants