title: How do I connect to a Azure Worker Role with tcp endpoint? Tech help needed with Tcp and Azure
body: <p>I created a worker role in visual studio and deployed it to Azure.  Azure shows it is running on my staging. </p>
  
  <p>On my cloud services screen there is a URL for the service, but that doesn't seem to do anything when I ping it or just navigate there.  I get:</p>
  
  <p>This webpage is not available</p>
  
  <p>ERR_NAME_NOT_RESOLVED</p>
  
  <p>I wrote the following code to try and access the service through a TcpClient:</p>
  
  <pre><code>    string ip = "http://mysite.cloudapp.net";
      int port = 10;
      TcpClient client = new TcpClient();
  
      try
      {
          client.Connect(ip, port);  // This line throws the error.
  
          if (client.Connected)
          {
              client.Close();
          }
      }
      catch (Exception ex)
      {
          Trace.Warn(ex.Message);
      }
  </code></pre>
  
  <p>On client.Connect(ip, port) There is an error that says 
  <strong>Message = "The requested name is valid, but no data of the requested type was found"</strong></p>
  
  <p>My WorkerRole has the following Run method (copied from an online tutorial i believe).</p>
  
  <pre><code>public override void Run()
  {
      Trace.TraceInformation("wr is running");
  
  
      TcpListener listener = null;
  
      try
      {
          listener = new TcpListener(
              RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["myEndpoint"].IPEndpoint);
          listener.ExclusiveAddressUse = false;
          listener.Start();
      }
      catch (SocketException)
      {
          Trace.Write("Echo server could not start.", "Error");
          return;
      }
      while (true)
      {
          IAsyncResult result = listener.BeginAcceptTcpClient(HandleAsyncConnection, listener);
          connectionWaitHandle.WaitOne();
      }
  }
  </code></pre>
  
  <p>Finally in my csdef my endpoint appears like so:</p>
  
  <pre><code>&lt;InputEndpoint name="myEndpoint" protocol="tcp" port="10" localPort="10" /&gt;
  </code></pre>
  
  <p>I'd like to get the connection talking back and forth.</p>