socket.IPPROTO_IPV6 undefined in Python 2.7.12 for Windows #138

Closed
nicolasrozain opened this Issue Sep 28, 2016 · 6 comments

Projects

None yet

3 participants

@nicolasrozain
nicolasrozain commented Sep 28, 2016 edited

Hi all,

In the current commit (7e807c9), the line 172 of the file waitress/server.py contains:

self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)

Thing is, IPPROTO_IPV6 is not defined in socket...

Should it be replaced by its value (41) defined in Ws2def.h, while we gently wait for Python to fix this ?
Or should IPV6 be avoided under Windows with Python 2.7 ?

Thanks for the support,

Best,
Nicolas

@bertjwregeer
Member
bertjwregeer commented Sep 28, 2016 edited

Lovely: https://bugs.python.org/issue6926

I'd accept a patch that tried to use the value from socket and if not available set it to 41 explicitly and imports it from compat, so that compat.IPPROTO_IPV6 was in Linux/Unix socket.IPPROTO_IPV6 and when not available it's hard coded.

Not a big fan, but alas we are stuck with it.

@bertjwregeer
Member

BTW, it looks like it won't ever be fixed for Python 2.7 on Windows. So waiting is not an option. I'd recommend Python 3.5 anyway. IPv6 support should work just fine on Windows, although the testing that is currently done is done on AppVeyor on Python 3.5 only.

@kedare
kedare commented Oct 14, 2016

I get the same message with Python 3.5.2 when trying to run devpi-server:

Traceback (most recent call last):
  File "c:\runtimes\python35\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\runtimes\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Runtimes\Python35\Scripts\devpi-server.exe\__main__.py", line 9, in <module>
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 56, in main
    return _main(pluginmanager, argv=argv)
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 119, in _main
    return xom.main()
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 229, in main
    return wsgi_run(xom, app)
  File "c:\runtimes\python35\lib\site-packages\devpi_server\main.py", line 144, in wsgi_run
    serve(app, host=host, port=port, threads=50)
  File "c:\runtimes\python35\lib\site-packages\waitress\__init__.py", line 11, in serve
    server = _server(app, **kw)
  File "c:\runtimes\python35\lib\site-packages\waitress\server.py", line 78, in create_server
    sockinfo=sockinfo)
  File "c:\runtimes\python35\lib\site-packages\waitress\server.py", line 172, in __init__
    self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
AttributeError: module 'socket' has no attribute 'IPPROTO_IPV6'

What are the workarounds to be able to use it ? I don't care of IPv6 in my case.

@bertjwregeer
Member

@kedare Make sure to set your listen and or host/port combo to something that is explicitly IPv4 (127.0.0.1:8080 for example).

This won't activate any of the IPv6 code paths.

@bertjwregeer
Member
bertjwregeer commented Oct 14, 2016 edited

Also, what version of Windows? Looking at the bug report linked, it should be activated on Windows Vista and above... and thus should be available.

Are you using the 32 bit version of Python or the 64 bit version of Python?

@bertjwregeer
Member

Could someone pull down #140 and test that patch on Windows?

@bertjwregeer bertjwregeer closed this in #140 Oct 22, 2016
@clrpackages clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Oct 25, 2016
@fenrus75 fenrus75 + clrbuilder waitress: Autospec creation for update from version 1.0.0 to version …
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
66307a4
@clrpackages clrpackages pushed a commit to clearlinux-pkgs/waitress that referenced this issue Jan 11, 2017
@fenrus75 fenrus75 + clrbuilder waitress: Autospec creation for update from version 1.0.0 to version …
…1.0.1

1.0.1 (2016-10-22)
------------------

Bugfixes
~~~~~~~~

- IPv6 support on Windows was broken due to missing constants in the socket
  module. This has been resolved by setting the constants on Windows if they
  are missing. See Pylons/waitress#138

- A ValueError was raised on Windows when passing a string for the port, on
  Windows in Python 2 using service names instead of port numbers doesn't work
  with `getaddrinfo`. This has been resolved by attempting to convert the port
  number to an integer, if that fails a ValueError will be raised. See
  Pylons/waitress#139
a111daa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment