keifufu/PyWNP

Error when trying to bind socket to localhost rather than the loopback IP

Closed this issue · 1 comments

I'm having an issue using this project on Linux.
Whenever I try and run the Initialize function, I get the following error:
OSError: [Errno 99] error while attempting to bind on address ('172.0.0.1', 3333): cannot assign requested address

I believe that I have found the issue which is that when you call WNPRedux._server = serve(WNPRedux._onConnect, 'localhost', port) on line 147 of pywnp.py, you are trying to bind to localhost and not the loopback IP 127.0.0.1 which has been known to cause issues on devices with IPv6 disabled/unavailable (See WebSockets: Read the Docs - FAQ)

The easiest way to fix this would be to change localhost to to 127.0.0.1, but another parameter could be added to an overloaded version of the Initialize function to make it more configurable and avert issues if the user isn't using 127.0.0.1 as their loopback for whatever reason or allow the use of localhost in IPv6 environments.

Fixed in 1.0.2, added a fourth optional parameter to Initialize to specify the loopback address and changed it to use 127.0.0.1 by default