I'm having trouble making a TCP connection to a Windows virtual machine instance that I created in Google Cloud Platform's "Compute Engine". Within the Windows machine, I have tried specifically opening the ports I'm using (135 and 445). I've even tried disabling the firewall completely on that machine without any luck. Additionally, I've tried several configurations of the Firewall Rules within the VPC Network. Most recently, I've tried setting up a firewall rule to allow all ingress connections (target: all instances in the network, source ip ranges: 0.0.0.0/0, allow all protocols and ports) Firewall rule .
Oddly, I can connect through my Windows RDP client without any issue. However, when I try to connect using the following code in my C# app, I get an exception that reads:
"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"
. Code:
using (var client = new TcpClient())
{
var result = client.BeginConnect(machine, port, null, null);
var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(60), true);
if (success)
{
client.EndConnect(result);
return true;
}
}
}
catch (Exception ex)
{
if (logWriter != null)
{
logWriter.Debug(ex.Message + ". ");
}
}
The exception is thrown on the line with "client.EndConnect(result)". I cannot see my attempt to connect to port 135 in my firewall logs. I see my successful RDP connections and a connection to port 80 (which I didn't explicitly attempt). I've set a breakpoint in my code and confirmed that the "machine" variable resolves to my external ip on my VM and my "port" variable corresponds with port 135. It almost seems like there's something prior to my firewall blocking my connection, but I'm not sure what that would be