2

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

1

This is more of a comment than an answer (I don't have the reputation here yet on ServerFault) but maybe this question is best asked in Stackoverflow.

0

It looks like this was happening because my ISP is silently blocking my attempt to connect to Port 445. My local development machine and my GCP Windows VM are not on the same VPN or network. My attempts were likely blocked by my ISP because an external port 445 connection looked suspicious based on past vulnerabilities to this port (see https://www.grc.com/port_445.htm).

In my original question, I was focusing on opening ports within GCP and the VM, but the attempt seems to have been blocked before that point. After doing more research into the vulnerabilities on this port, it seems that attempting this on two machines that aren't on the same network isn't the best approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.