levelrin / jws-server

A framework for WebSocket server in Java
MIT License
0 stars 0 forks source link

ServerSocketGuideTest > portShouldBeUsedInServerSocket() FAILED #57

Closed levelrin closed 3 years ago

levelrin commented 3 years ago

We found out that some tests failed under WSL 2. This is the stack trace:

ServerSocketGuideTest > portShouldBeUsedInServerSocket() FAILED
    java.lang.IllegalStateException: Failed to instantiate the server socket.
        at com.levelrin.jwsserver.guide.ServerSocketGuide.port(ServerSocketGuide.java:57)
        at com.levelrin.jwsserver.guide.ServerSocketGuideTest.portShouldBeUsedInServerSocket(ServerSocketGuideTest.java:44)

        Caused by:
        Caused by:

        java.net.BindException: Permission denied
            at java.base/sun.nio.ch.Net.bind0(Native Method)
            at java.base/sun.nio.ch.Net.bind(Net.java:550)
            at java.base/sun.nio.ch.Net.bind(Net.java:539)
            at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:643)
            at java.base/java.net.ServerSocket.bind(ServerSocket.java:396)
            at java.base/java.net.ServerSocket.<init>(ServerSocket.java:282)
            at java.base/java.net.ServerSocket.<init>(ServerSocket.java:173)
            at com.levelrin.jwsserver.guide.ServerSocketGuide.port(ServerSocketGuide.java:55)
            ... 1 more
levelrin commented 3 years ago

We found out that the non-root users are not allowed to use the port less than 1024. We can solve the issue by using a port number greater than or equal to 1024.