Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App service VNet Integration doesn't work correctly when using a default TcpClient #45991

Closed
jgoyvaerts opened this issue Jan 11, 2020 — with docs.microsoft.com · 10 comments

Comments

Copy link

jgoyvaerts commented Jan 11, 2020

Situation:

  • Setup an app service and a vm which you want to reach from the app service.
  • Integrate everything with VNet integration
  • Attempt to connect from the App service to the VM by using a default TcpClient
using (TcpClient client = new TcpClient())
{
    await client.ConnectAsync("10.0.0.2", 1234);
}

The TcpClient will default to a IPv6 socket (because the OS supports it), and an exception will occur:
ExtendedSocketException: An attempt was made to access a socket in a way forbidden by its access permissions [ipv6 address]

Setting the tcpclient explicitly to AddressFamily.InterNetwork fixes the issue, but this isn't a solution when using third party libraries to perform the connection.

Not sure if this is a bug in .NET core or azure app service, but it severely limits the use of App Service VNet integration


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@DixitArora-MSFT
Copy link
Contributor

Hi @jgoyvaerts Thanks for reaching out. We will review and update as appropriate.

@AjayKumar-MSFT
Copy link
Contributor

Apologies for the delay! We had been checking on this internally. Your feedback has been shared with the content owner for further review.

@HoLengZai
Copy link

Hi,
Any update on that issue?
It seems I got a similar issue. When I send an email from my App Service without the Application Settings WEBSITE_VNET_ROUTE_ALL=1, I can send an e-mail to smtp.office365.com:587 without any issue using .Net Core 3.1 but as soon I set the value to route all outbound to the Vnet with the Vnet integration, i got the following message:

 System.Net.Mail.SmtpException: Failure sending mail.
  ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions. [::ffff:40.101.12.98]:587

In the meantime, i'm going to use Mailkit as recommended on MS docs to handle modern auth mode. Hope this issue will be fixed soon

@HoLengZai
Copy link

Hi,
I got a ticket with MS Support, and indeed the issue is that some client libraries don't force IPv4 (as TcpClient) as the virtual NIC installed on the App Services workers (for regional VNet integration) don't support IPv6.

Since SmtpClient relies on TcpClient, using Mailkit fixed my issue to send e-mail to smtp.office365.com:587.

In the meantime, it will be great that this issue is documented on MS docs website
https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet#regional-vnet-integration

@fgarcia-cnb
Copy link

We just experienced the same issue with the System.Net.Mail smtpclient. Mailkit works, but we also got another possible fix from MS support: Add the following app setting:

WEBSITE_VNET_SUPPORT_DUAL_STACK_SOCKETS=1

did the trick for us

@JohnYoungers
Copy link

@fgarcia-cnb that setting resolved our problem yesterday as well: Thank you!

What are the odds I'd be viewing an issue that hasn't been commented on in 6 months and a magical solution appears that moment.

@RyanHill-MSFT
Copy link
Contributor

Apologies for the delayed response regarding adding WEBSITE_VNET_SUPPORT_DUAL_STACK_SOCKETS but glad it was able to resolve the issue.

@lonevvolf
Copy link
Contributor

Is the WEBSITE_VNET_SUPPORT_DUAL_STACK_SOCKETS setting documented anywhere other than here?

@RyanHill-MSFT
Copy link
Contributor

I didn't see @lonevvolf. I'll get this added to https://docs.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet and mention it usage in this doc.

Apologies for that.

@techmantel
Copy link

techmantel commented Mar 14, 2024

@RyanHill-MSFT Can't find this in the documentation link you referred to. As a matter of fact, can't find it anywhere in any official documentation. Am I just bad at googling or is it still not documented? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests