wcf System.ServiceModel.AddressAlreadyInUseException

发布于 2024-07-12 10:48:08 字数 3693 浏览 5 评论 0原文

如果这个问题在 stackOverflow 上出现两次,我深表歉意

我正在尝试在 Windows Server 2003 机器上运行 WCF 服务。 当服务主机调用 Open() 时,我收到 System.ServiceModel.AddressAlreadyInUseException 异常,它告诉我以下错误:

HTTP 无法注册 URL http://+:8080/LogoResizer/mex/,因为TCP 端口 8080 正被另一个应用程序使用

我读到我需要使用 httpcfg.exe 来注册我的命名空间,并且我使用了找到的 GUI 工具 此处 执行此操作,但我仍然收到上述异常。 运行“netstat -a”不会显示任何其他在端口 8080 上侦听的内容,并且运行“httpcfg.exe query urlacl”会返回以下已注册的命名空间。

C:\Program Files\Support Tools>httpcfg 查询 urlacl 网址:http://+:80/Temporary_Listen_Addresses/

ACL:D:(A;;GX;;;WD)

URL : http://+:8080/LogoResizer/

ACL : D:(A;;GX;;;WD)

URL : http://+:8080/LogoResizer/mex/

ACL : D:(A;;GX;;;WD)

我的应用程序的配置如下:

<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647"
                              maxStringContentLength="2147483647"
                              maxArrayLength="2147483647"
                              maxBytesPerRead="2147483647"
                              maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>

        </netTcpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior">
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:900/mex/"/>
                    <add baseAddress="net.tcp://localhost:9000/" />
                </baseAddresses>
            </host>
            <endpoint bindingConfiguration="NetTcpBinding_ImageResizerServiceContract" binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
            <endpoint  address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>

有谁知道我做错了什么或如何注册我的命名空间,以便为我的服务提供 http 端点?

Apologies if this question appears twice on stackOverflow

Im trying to run a wcf service on a windows server 2003 box. Im getting a System.ServiceModel.AddressAlreadyInUseException exception when the servicehost calls Open() and it tells gives me the following error:

HTTP could not register URL http://+:8080/LogoResizer/mex/ because TCP port 8080 is being used by another application

Ive read that I need to use the httpcfg.exe to register my namespace and Ive used the GUI tool found here to do it but I still get the above exception. Running "netstat -a" doesnt show anything else listening on port 8080 and running "httpcfg.exe query urlacl" returns me the following registered namespaces.

C:\Program Files\Support Tools>httpcfg query urlacl
URL : http://+:80/Temporary_Listen_Addresses/

ACL : D:(A;;GX;;;WD)

URL : http://+:8080/LogoResizer/

ACL : D:(A;;GX;;;WD)

URL : http://+:8080/LogoResizer/mex/

ACL : D:(A;;GX;;;WD)

The config for my app is as below:

<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647"
                              maxStringContentLength="2147483647"
                              maxArrayLength="2147483647"
                              maxBytesPerRead="2147483647"
                              maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                <security mode="Transport">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" />
                </security>
            </binding>

        </netTcpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior">
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:900/mex/"/>
                    <add baseAddress="net.tcp://localhost:9000/" />
                </baseAddresses>
            </host>
            <endpoint bindingConfiguration="NetTcpBinding_ImageResizerServiceContract" binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
            <endpoint  address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>

Does anyone have any idea what Im doing wrong or how I can register my namespace so I can have a http endpoint for my service?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瓜 2024-07-19 10:48:08

解决了。

问题是我的两个端点都在同一个端口上运行。 在 Windows XP 下开发时,这不是问题,但在 Vista 或 Windows Server 2003 下尝试运行该服务时,会出现我所写的例外情况。我只需要将服务器配置更新为以下内容

   <baseAddresses>
                                    <add baseAddress="http://localhost:9000/mex/"/>
                                    <add baseAddress="net.tcp://localhost:9001/" />
                            </baseAddresses>

Worked it out.

Problem was having both my endpoints running off the same port. This isnt an issue when developing under windows XP, but will give you the exceptions I wrote about when trying to run the service under Vista or windows server 2003. I just needed to update my server config to the following

   <baseAddresses>
                                    <add baseAddress="http://localhost:9000/mex/"/>
                                    <add baseAddress="net.tcp://localhost:9001/" />
                            </baseAddresses>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文