I'm trying to configure Springboot(Tomcat) to start using unix-socket in Windows, but I get an error "Address already in use: bind". I have my own connector with port 0, but in debug mode it appears to be -1 (I don't think it's causes this exception though). I'm totaly new to this topic so will appreciate any pieces of advice where to start from. Or any examples. Thanks in advance. Here's my configuration:
@Configuration
public class TomcatConfiguration {
@Bean
public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers(
connector -> {
connector.setPort(0);
connector.setScheme("http");
connector.setProperty("socketFactoryClassName", "org.apache.tomcat.jni.SocketFactory");
connector.setProperty("socketFactoryEncoding", "UTF-8");
try {
UnixDomainSocketAddress address = UnixDomainSocketAddress.of(SOCKET_FILE);
StandardProtocolFamily family = StandardProtocolFamily.UNIX;
ServerSocketChannel server = ServerSocketChannel.open(family);
server.bind(address);
server.accept();
} catch (Exception e) {
e.printStackTrace();
}
}
);
return factory;
}
}