How can I make IIS handle net.tcp connections?
In the Name column of the list of services, right-click the Net. Tcp Port Sharing Service, and select Properties from the menu. To enable the manual start-up of the service, in the Properties window select the General tab, and in the Startup type box select Manual, and then click Apply.
Open IIS=> in Connections panel=> expand Sites=>Select your website=>Go to Right site Action Pane=> click on Advanced Settings=> Expand the 'Behavior' section In the field 'Enable Protocols' set these below values by commas, (http,net. tcp,net.
net. tcp is simply the URI scheme used within Windows to identify endpoints that can be accessed using TCP. Similarly, net. msmq and net. pipe , are the URI schemes to address endpoints that utilise the MSMQ protocol and Named Pipes protocol, respectively.
Tcp Listener Adapter (NetTcpActivator) service receives activation requests over the net. tcp protocol and passes them to the Windows Process Activation Service. This service is not installed by default. It can be added using the Turn Windows Features on or off option in the Control Panel.
You need to add net.tcp
to the enabled protocols of your site. Go to IIS Manager, right-click on your website, go to 'Manage Web Site' or 'Manage Application', then to 'Advanced Settings...'. There you see 'Enabled Protocols'. It probably says http
. Change it to http,net.tcp
.
If you want to configure bindings, right-click on your website and go to 'Edit Bindings...'. The default net.tcp binding is 808:*
.
If you want to use WCF services hosted by IIS behind net.tcp, you may also want to check whether you have activated the required Windows Features. Go to your Windows Features and check you have activated 'Windows Communication Foundation Non-HTTP Activation' (found under 'Microsoft .NET Framework 3.5.1').
When you activate this feature, you will get some extra Windows Services. If it still doesn't work, check that the Windows Service named 'Net.Tcp Listener Adapter' is running (should start automatically but sometimes it doesn't and this is the first place I check when one of my net.tcp
services stops working).
This might help someone in the future. I created a powershell
script that will come in useful if you need to automate the creation of the bindings.
It will automatically check if the binding exists already and only add it when required.
Actual Script
Import-Module WebAdministration
$websites = Get-ChildItem 'IIS:\Sites'
$site = $websites | Where-object { $_.Name -eq 'Default Web Site' }
$netTcpExists = [bool]($site.bindings.Collection | ? { $_.bindingInformation -eq '808:*' -and $_.protocol -eq 'net.tcp' })
if (!$netTcpExists)
{
Write-Output "Net TCP binding does not exist. Creating binding now..."
# Create the binding
New-ItemProperty 'IIS:\Sites\Default Web Site' -name bindings -Value @{protocol="net.tcp";bindingInformation="808:*"}
Write-Output "Binding created"
}
else
{
Write-Output "TCP Binding already exists"
}
Write-Output "Updating enabled protocols..."
Set-ItemProperty 'IIS:\sites\Default Web Site' -name EnabledProtocols -Value "http,net.tcp"
Write-Output "Enabled protocols updated"
The last step worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With