Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting a Listening Tentacle on Windows results in a port is already in use error. #725

Closed
1 task done
nathanwoctopusdeploy opened this issue Dec 5, 2023 · 1 comment · Fixed by #716
Closed
1 task done
Assignees
Labels
team/server-at-scale Represents the Server at Scale team under the Hosting & Execution Group

Comments

@nathanwoctopusdeploy
Copy link
Contributor

nathanwoctopusdeploy commented Dec 5, 2023

Team

  • I've assigned a team label to this issue

What happened?

When a Windows Listening Tentacle is restarted, it may fail to free up the port being used for incoming requests. This can result in an error when trying to restart Tentacle and may result in a 1-2 minute period where Tentacle cannot start.

Reproduction

Impacts versions 8.0.0 to 8.1.61

Error and Stacktrace

2023-12-01 04:00:02.6299   3692      9  INFO  ==== RunAgentCommand ====
2023-12-01 04:00:02.6299   3692      9  INFO  CommandLine: C:\Tentacle\PFiles\Octopus Deploy\Tentacle\Tentacle.dll run --instance=Tentacle
2023-12-01 04:00:02.8534   3692      9 ERROR  A required communications port is already in use. The required port is being used by another process. The Windows `netstat -o -n -a` command can be used to show which process this is (compare PIDs with those shown in Task Manager). See: http://g.octopushq.com/HttpPortInUse
System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.Net.Sockets.TcpListener.Start(Int32 backlog)
   at System.Net.Sockets.TcpListener.Start()
   at Halibut.Transport.SecureListener.Start()
   at Halibut.HalibutRuntime.Listen(IPEndPoint endpoint)
   at Octopus.Tentacle.Communications.HalibutInitializer.Start() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Communications\HalibutInitializer.cs:line 47
   at Octopus.Tentacle.Commands.RunAgentCommand.Start() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Commands\RunAgentCommand.cs:line 126
   at Octopus.Tentacle.Startup.AbstractCommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\AbstractCommand.cs:line 79
   at Octopus.Tentacle.Startup.OctopusProgram.Start(ICommandRuntime commandRuntime) in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\OctopusProgram.cs:line 544
   at Octopus.Tentacle.Startup.WindowsServiceHost.<>c__DisplayClass2_0.<Run>b__0() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\WindowsServiceHost.cs:line 23
   at Octopus.Tentacle.Startup.WindowsServiceAdapter.RunService() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\WindowsServiceAdapter.cs:line 44
2023-12-01 04:00:02.9371   3876      1  INFO  Waiting for service to become Running. Current status: Running
2023-12-01 04:00:03.0513   3692      9 FATAL  Unhandled AppDomain exception occurred: A required communications port is already in use. The required port is being used by another process. The Windows `netstat -o -n -a` command can be used to show which process this is (compare PIDs with those shown in Task Manager). See: http://g.octopushq.com/HttpPortInUse
System.Exception
   at Octopus.Tentacle.Startup.WindowsServiceAdapter.RunService() in WindowsServiceAdapter.cs:line 52
   at System.Threading.Thread.StartCallback()

--Inner Exception--
Only one usage of each socket address (protocol/network address/port) is normally permitted.
System.Net.Sockets.SocketException
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.Net.Sockets.TcpListener.Start(Int32 backlog)
   at System.Net.Sockets.TcpListener.Start()
   at Halibut.Transport.SecureListener.Start()
   at Halibut.HalibutRuntime.Listen(IPEndPoint endpoint)
   at Octopus.Tentacle.Communications.HalibutInitializer.Start() in HalibutInitializer.cs:line 47
   at Octopus.Tentacle.Commands.RunAgentCommand.Start() in RunAgentCommand.cs:line 126
   at Octopus.Tentacle.Startup.AbstractCommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in AbstractCommand.cs:line 79
   at Octopus.Tentacle.Startup.OctopusProgram.Start(ICommandRuntime commandRuntime) in OctopusProgram.cs:line 544
   at Octopus.Tentacle.Startup.WindowsServiceHost.<>c__DisplayClass2_0.<Run>b__0() in WindowsServiceHost.cs:line 23
   at Octopus.Tentacle.Startup.WindowsServiceAdapter.RunService() in WindowsServiceAdapter.cs:line 44
System.Exception: A required communications port is already in use. The required port is being used by another process. The Windows `netstat -o -n -a` command can be used to show which process this is (compare PIDs with those shown in Task Manager). See: http://g.octopushq.com/HttpPortInUse
 ---> System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.Net.Sockets.TcpListener.Start(Int32 backlog)
   at System.Net.Sockets.TcpListener.Start()
   at Halibut.Transport.SecureListener.Start()
   at Halibut.HalibutRuntime.Listen(IPEndPoint endpoint)
   at Octopus.Tentacle.Communications.HalibutInitializer.Start() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Communications\HalibutInitializer.cs:line 47
   at Octopus.Tentacle.Commands.RunAgentCommand.Start() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Commands\RunAgentCommand.cs:line 126
   at Octopus.Tentacle.Startup.AbstractCommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\AbstractCommand.cs:line 79
   at Octopus.Tentacle.Startup.OctopusProgram.Start(ICommandRuntime commandRuntime) in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\OctopusProgram.cs:line 544
   at Octopus.Tentacle.Startup.WindowsServiceHost.<>c__DisplayClass2_0.<Run>b__0() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\WindowsServiceHost.cs:line 23
   at Octopus.Tentacle.Startup.WindowsServiceAdapter.RunService() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\WindowsServiceAdapter.cs:line 44
   --- End of inner exception stack trace ---
   at Octopus.Tentacle.Startup.WindowsServiceAdapter.RunService() in C:\BuildAgent\work\cce1880bf18fcb0c\source\Octopus.Tentacle\Startup\WindowsServiceAdapter.cs:line 52
   at System.Threading.Thread.StartCallback()
2023-12-01 04:00:03.2495   3876      1  INFO  Service started
2023-12-01 04:00:56.1878   1312      1  INFO

More Information

No response

Workaround

Wait for 1-2 minutes and then restart Tentacle

@nathanwoctopusdeploy nathanwoctopusdeploy added the team/server-at-scale Represents the Server at Scale team under the Hosting & Execution Group label Dec 5, 2023
@nathanwoctopusdeploy nathanwoctopusdeploy self-assigned this Dec 5, 2023
@nathanwoctopusdeploy nathanwoctopusdeploy changed the title Restarting a Listening Tentacle on Windows results in a port is already in use error. Restarting a Listening Tentacle on Windows results in a port is already in use error. Dec 5, 2023
@octoreleasebot
Copy link

Release Note: Fix an issue where restarting a Windows Listening Tentacle may not free up the listening port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team/server-at-scale Represents the Server at Scale team under the Hosting & Execution Group
Projects
None yet
2 participants