1
votes

I have an azure Queue trigger function that has this code:

using (var client = new TcpClient(AddressFamily.InterNetworkV6))
{
   client.Client.DualMode = true;
   client.Connect(endpoint);

   var data = Encoding.ASCII.GetBytes("test");

   using (var outStream = client.GetStream())
   {
        outStream.Write(data, 0, data.Length);
   }
}

The error I am getting back:

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

The endpoint address looks correct and this code works when I debug locally, so I suspect that the azure server might not be allowing the outbound connection.

Any ideas why this connection is not working?


Update: This is still not working and I have tried generating the client in the following ways:

// DualMode IPV6
var client = new TcpClient(AddressFamily.InterNetworkV6);
client.Client.DualMode = true;
client.Connect(endpoint);

// SingleMode Internetwork
var client = new TcpClient(AddressFamily.InterNetwork);
client.Connect(endpoint);

// Just Endpoint
var client = new TcpClient(endpoint);
client.Connect(endpoint);

// Normal
var client = new TcpClient(hostAddress, port);

// Forced IPV6
var client = new TcpClient("::ffff:" + hostAddress, port);

Debugging locally, all of these methods except for "forced IPV6" work just fine. On the server, I get these errors:

== DualMode IPV6
    Failed PingBack: 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 [::ffff:204.16.184.62]:3164

== SingleMode Internetwork
    Failed PingBack: 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 204.16.184.62:3164

== Just Endpoint
    Failed PingBack: The requested address is not valid in its context

== Normal
    Failed PingBack: 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 204.16.184.62:3164

== Forced IPV6
    Failed PingBack: The requested address is not valid in its context [::ffff:204.16.184.62]:3164
1
I am not quite sure about what your code is doing ? you try to send data to another endpoint ? On Azure ?? Coud you explain a little bit more your contextThomas
I'm setting up a push service that communicates back to clients that call an azure httptrigger function. I get the address from "X-Forwarded-For" in the MS_HttpContext value from the environment of the function. I've verified that the address is correct.Eric Jorgensen
So someone post something using an http trigger, the http triggered function enqueue a message. The queue trigger function read the callback url and try to send data ?Thomas
Yes. HttpTrigger stores the remote address:port in a queue message. QueueTrigger tries to send data to the address:port. Again, this works fine locally, but not on the server.Eric Jorgensen
Do you have any ip restriction ??Thomas

1 Answers

2
votes

Looking at your TcpClient instance,

var client = new TcpClient(AddressFamily.InterNetworkV6)

there's no IPv6 in Azure Functions yet. Switch your AddressFamily to v4:

var client = new TcpClient(AddressFamily.InterNetwork)

There are no restrictions on outbound desinations in App Service/Functions.