Unix socket not deleted at startup in Blazor.DevServer
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hello
I want to use nginx as frontend to be able to use a TLS certificate with a specific hostname on linux, I would like to use a unix socket instead of assigning a port, to avoid possible conflict, and since the nginx configuration is static I cannot assign port dynamically.
Expected Behavior
The unix socket should be deleted if it exists at startup
Steps To Reproduce
ASPNETCORE_URLS=http://unix:/var/run/app/app.sock dotnet run
Exceptions (if any)
Unhandled exception. System.IO.IOException: Failed to bind to address http://unix:/var/run/app/app.sock: address already in use.
---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
---> System.Net.Sockets.SocketException (98): Address already in use
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions.CreateDefaultBoundListenSocket(EndPoint endpoint)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass30_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Microsoft.AspNetCore.Components.WebAssembly.DevServer.Program.Main(String[] args)
.NET Version
7.0.100
Anything else?
No response
Issue Analytics
- State:
- Created 8 months ago
- Comments:24 (15 by maintainers)
Top Results From Across the Web
Unix socket not deleted at startup in Blazor.DevServer
Unix socket not deleted at startup in Blazor.DevServer · Summary · Jobs. backport. cleanup · run_backport · Run details. Usage · Workflow file....
Read more >Unix domain socket file not removed on application crash
It explains that: "Abstract sockets automatically disappear when all open references to the socket are closed.". Using "close-behind semantics":.
Read more >Why aren't UNIX domain sockets removed automatically ...
The only thing one can (and has to) do is unlink . Shouldn't OS remove socket file from file system automatically when it's...
Read more >A fun community for developers to connect over code, tech ...
Team(not his team, he just happened to sit next to us): php/frontend devs and Linux (server) people. Team: starting a new project! We'll...
Read more >W3layouts cms exploit
denyCurrentBranch' configuration variable to 'deny' 'router outlet' is not a known element 'scriptcs' not recognized as an internal or external command, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Nginx run as root in background I don’t need to start it from my IDE thus my IDE do not run as root (which would be very bad on a security level).
Nginx communicate with a unix socket, a file with the right permission to allow only my user to create it and only nginx to read connect to it. This is common on linux, for example php-fpm works like this too.
Also even if I could start kestrel on port 80/443 as non root by changing the config with sysctl (I think
net.ipv4.ip_unprivileged_port_startwould allow me to do that, but I don’t think this would be a good idea anyway) I’m having multiple services running and nginx is also doing the dispatch depending on the hostname to the right host.Since I´m working on different projects, having numeric port is not an options, I don’t want to start managing excel with what port use what project and what avoid conflict with other services. With a unix socket, all this disapear
If this can help to understand how my setup is working I did a little graph, if you need more information let me know. If you have a better idea I’ll be happy to hear it too. But here I’m using nginx exactly as people are using IIS on windows.
The bot closed this again,
@adityamandaleeka I’m sincerly curious about a scenario where deleteing a unix socket when no server is listening on it could be problematic.