'Domain Sockets with Spring boot & Netty

I am trying to use Unix Domain sockets with Spring boot ver. 2.6.4 on Windows 10. Here is the code for a simple server that I am trying to bootstrap

    @SpringBootApplication
public class UdsApplication {

    public static void main(String[] args) {
        SpringApplication.run(UdsApplication.class, args);
    }

    @PostConstruct
    public void init(){
        Path socketPath = Path.of(System.getProperty("user.home")).resolve("test2.socket");
        UnixDomainSocketAddress domainSocketAddress = UnixDomainSocketAddress.of(socketPath);
        DisposableServer server =
                HttpServer.create()
                        .route(routes ->
                                routes.get("/hello2",
                                        (request, response) -> response.sendString(Mono.just("Hello World2!"))))
                        .bindAddress(() -> domainSocketAddress)
                        .bindNow();
        server.onDispose().block();
    }

}

I see the following error on Startup:

Caused by: java.nio.channels.UnsupportedAddressTypeException: null
    at java.base/sun.nio.ch.Net.checkAddress(Net.java:146) ~[na:na]
    at java.base/sun.nio.ch.Net.checkAddress(Net.java:157) ~[na:na]
    at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:330) ~[na:na]
    at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294) ~[na:na]
    at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134) ~[netty-transport-4.1.74.Final.jar:4.1.74.Final]

My question is - Does Netty support Unix Domain Sockets on Windows 10 ? The same code works on Linux. Thanks.



Solution 1:[1]

Netty currently supports Unix Domain Sockets only for the native transport so you cannot use this functionality on Windows where only NIO transport is available. There is a feature request for the requirement that you have.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Violeta Georgieva