Windows Service with Automatic (Delayed Start) fails to open a socket - windows

I have a Windows Service which recently was set to Automatic(Delayed Start) from Automatic because sometimes it was failing to start and that would have required manual intervention to start it.
But on one of the machines we are testing with the service failed to open a socket on TCP port 5000.
The error is the following:
Initialize(): System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
There is a rule on the firewall to allow the service to listen on TCP
port 5000
Restarting the service results in the same socket error
netstat -o does not show any other process listening on TCP port 5000. Only on System start up I had one instance of the following: TCP [::1]:5000 PrecisionLab01:49844 TIME_WAIT 0
Returning the service to Automatic startup resolves the issue. No other system of our 4 test machines has that problem when the service is set for Automatic (Delayed Start)
Is there a way to diagnose which app is responsible for making the System kernel process to claim TCP port 5000?
Thank you in advance.

Related

The jmeter httpclient4 is causing ephemeral TCP ports exhaustion whereas httpclient3 is not causing in the windows machine

I am running a load test with 600 users using httpclient-3 & httpclient-4 implementation in windows server 2012R2 machine. During the httpclient-4 test after 200 users ramped-up I am facing the ephemeral TCP ports exhaustion, this is not occurring even when I run 1000 users with httpclient-3.
I understand there is a workaround like increasing the ephemeral ports and enabling fast recycling TIME_WAIT sockets to resolve the issue.
I am curious to know is there anyway with the help of jmeter properties can we resolve the ephemeral TCP ports exhaustion.
Error: Non HTTP response code: java.net.BindException,Non HTTP response message: Address already in use

Connecting to MSMQ from remote machine

I'm trying to connect to MSMQ running on an AWS EC2 instance using the following connection :
MessageQueue = new MessageQueue("FormatName:Direct=TCP:xx.xxx.xx.xxx\\private$\\TestQueue");
I've enabled all the appropriate traffic with the AWS security group and windows firewall. The error I'm getting is "Remote computer is not available."
Is MSMQ meant to work between windows machines which are not in the same domain, and without having to use HTTP ?
I'm including this netstat trace because it looks like MSMQ service is not listening on the public interface, but not sure how to fix this if it is the issue.
C:\Users\Administrator>netstat -abno | findstr 1801
TCP 0.0.0.0:1801 0.0.0.0:0 LISTENING 4184
TCP [::]:1801 [::]:0 LISTENING 4184

Connection from IIS7 to sql server fails when outbound traffic is blocked

I'm using windows 2008 R2 with IIS 7.5 (default config) trying to configure my firewall to block all outgoing connections, to prevent malicious attacks from "phoning home".
What outgoing rules do I need to create to enable the web application to connect to SQL Server default instance? The SQL server is under my control and it's running port 1433 for sure.
The webserver works fine. But the connect to DB step fails.
When I ping the sql server 2012 from the web server, I get the following:
Pinging xxx.0.0.xxx with 32 bytes of data:
General failure.
General failure.
General failure.
General failure.
I have already tried the following:
Created an outbound rule for port 1433 for w3wp.exe for port 1433
Created an outbound rule for WWWPublishing service for port 1433
When the above failed, I created an outbound rule for ALL programs
and applications for 1433, still no go.
When all failed. I tried to enable ALL the included rules in the
list, still didn't help
Tried connection string with data source=xxx.0.0.xxx and data
source=xxx.0.0.xxx,1433 both worked with outbound allowed, and both faild when outbound is blocked.
Created a new rule to enable RPC, so I created a rule for all TCP
traffic for services.exe
The only way to get it to connect, is to change the default behavior for the firewall to Allow outgoing traffic.
Just to reiterate, the only connection that is failing is web-server-> sql server.
Internet to Web server is fine.
Which port/program am I missing?
1433 is the port your remote machine listens to not the outgoing port of the clients.
Outgoing ports are dynamically assigned by the OS.
Go on a process basis.
An outbound rule All Ports of w3wp to 1433 works.

Cannot reach socket server on AWS EC2

I am trying to run a socket server on an Amazon Web Services EC2 instance. The socket is able to run just fine on it's own, and telnetting locally on the instance can connect, but trying to telnet to the socket from the outside is failing. I have gone into the security groups to ensure the ports I am using are open for both TCP and UDP (though the socket server has been configured for TCP). Is there something else I am missing?
The server might be listening on the loopback interface or ipv6 by default. You can check that by running netstat --listen -p which will show you which program listens on which address/port. How to make the program listen on the external ipv4 interface depends on the program/programming language.

Is it possible to open a 'local machine only' socket on Windows?

I'm wondering whether or not it's possible to configure a TCP socket such that it cannot accept connections from 'off-machine'.
I want to spin up an HTTP server that should only be accessible from clients running on the same machine, and although I can always filter out 'unauthorized' requests from off-machine, I would prefer it if this local-only behaviour were baked-in.
Also, opening a socket on windows triggers a firewall warning and request for the user to block/unblock the port being opened. I'm hoping that a means exists to avoid this message, if the socket can be configured to only accept local connections.
Bind to loopback interface, ip 127.0.0.1.

Resources