64

如何让IIS处理net.tcp连接?

4

4 回答 4

125

您需要添加net.tcp到站点的启用协议。转到 IIS 管理器,右键单击您的网站,转到“管理网站”或“管理应用程序”,然后转到“高级设置...”。在那里你会看到“启用的协议”。它大概说http。将其更改为http,net.tcp.

如果要配置绑定,请右键单击您的网站并转到“编辑绑定...”。默认的 net.tcp 绑定是808:*.

如果您想使用 net.tcp 后面的 IIS 托管的 WCF 服务,您可能还需要检查您是否已激活所需的 Windows 功能。转到您的 Windows 功能并检查您是否已激活“Windows Communication Foundation 非 HTTP 激活”(位于“Microsoft .NET Framework 3.5.1”下)。

当您激活此功能时,您将获得一些额外的 Windows 服务。如果它仍然不起作用,请检查名为“Net.Tcp 侦听器适配器”的 Windows 服务是否正在运行(应该自动启动,但有时它不会,这是我的一个net.tcp服务停止工作时我首先检查的地方)。

于 2010-07-06T17:32:04.153 回答
8

这可能对将来的某人有所帮助。我创建了一个脚本,如果您需要自动创建绑定powershell,它将派上用场。

它将自动检查绑定是否已经存在,并且仅在需要时添加它。

实际脚本

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"
于 2015-09-22T14:06:28.053 回答
4

最后一步对我有用。

  1. 确保在网站的“高级设置”中定义了这些协议 在此处输入图像描述
  2. 确保已安装以下功能 在此处输入图像描述
  3. 下面的服务应该正在运行 在此处输入图像描述
  4. 您的应用程序池应使用集成管道
  5. 关闭 IIS 管理器,重置 IIS,然后再次打开 IIS 管理器
  6. 检查 applicationHost.config 文件中的 listenerAdapters 部分(位于 C:\Windows\System32\inetsrv\config)。如果您没有看到要在绑定中使用的那些侦听器适配器,请手动添加它们 在此处输入图像描述 来源:IIS 中缺少绑定(net.tcp、net.pipe、net.msmq、msmq.formatname)
于 2019-07-29T18:11:52.680 回答
0

在我的例子中,我必须将 net.tcp 协议不仅添加到网站,而且添加到它下面的应用程序(右键单击应用程序、高级设置、启用的协议)。

于 2021-11-11T09:20:18.013 回答