简体   繁体   English

在azure vm windows服务器上自托管wcf服务

[英]Self hosted wcf service on azure vm windows server

I have wcf service with udp binding (new in WCF 4.5) and I'm trying to host it on Windows Server 2012 on Azure. 我有ucp绑定的wcf服务(WCF 4.5中的新功能),我正在尝试在Azure上的Windows Server 2012上托管它。

I did endpoint mapping on Azure for port I need (39901; it works for HTTP:80, I can see IIS website) and I allowed all traffic in firewall for this port. 我在Azure上为端口映射做了我需要的端口(39901;它适用于HTTP:80,我可以看到IIS网站)并且我允许防火墙中的所有流量用于此端口。 But I still can't get wsdl in web browser. 但我仍然无法在网络浏览器中获得wsdl。

Here is app.config for console app: 这是控制台应用程序的app.config:

<configuration>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentCalls="12" maxConcurrentInstances="56" maxConcurrentSessions="12" />
                <useRequestHeadersForMetadataAddress></useRequestHeadersForMetadataAddress>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service name="ServerService.UdpServiceAlpha">
            <endpoint address="soap.udp://localhost:8091" binding="udpBinding" contract="ServerService.IUdpServiceAlpha" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:39901/SelfServerHost/" />
                </baseAddresses>
            </host>
        </service>
    </services>
    <protocolMapping>
        <add binding="udpBinding" scheme="soap.udp" />
    </protocolMapping>
    <bindings>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>

For localhost everything works fine... I'm new in this (azure, windows server deployment) and I tried a lot of ideas here on stackoverflow or anywhere else. 对于本地主机,一切正常......我是新手(天蓝色,Windows服务器部署),我在stackoverflow或其他任何地方尝试了很多想法。 But still not working. 但仍然没有工作。

Any idea? 任何想法?

EDIT1: EDIT1:

<services>
        <service name="ServerService.UdpServiceAlpha" behaviorConfiguration="UdpServiceAlpha.Behavior">

            <endpoint address="/" binding="udpBinding" contract="ServerService.IUdpServiceAlpha"/>
            <endpoint address="/" binding="webHttpBinding" contract="ServerService.IUdpServiceAlpha"/>
            <host>
                <baseAddresses>
                    <add baseAddress="http://xxx.cloudapp.net:39901/SelfServerHost/" />
                    <add baseAddress="soap.udp://xxx.cloudapp.net:39901/SelfServerHost/" />
                </baseAddresses>
            </host>
        </service>
    </services>

Try changing the Azure VM Endpoint public port from 39901 to 443! 尝试将Azure VM端点公共端口从39901更改为443!

A hell lot of sys-admins and ISPs block all outgoing ports, and only allow few (outgoing port white listing). 很多系统管理员和ISP阻止所有传出端口,只允许少量(传出端口白名单)。 Port 80 and 443 are usually never blocked because it is usually HTTP traffic. 端口80和443通常从不被阻止,因为它通常是HTTP流量。

Change only the public port for the VM Endpoint. 仅更改VM端点的公共端口。 Leave the private port as is - 39901. 保留私有端口 - 39901。

Your configuration file seems to have a few issues: 您的配置文件似乎有一些问题:

The service behavior is missing a name: 服务行为缺少名称:

  <serviceBehaviors>
        <behavior name="my.service.behavior"> ...

The service needs to reflect the binding configuration 该服务需要反映绑定配置

<service name="ServerService.UdpServiceAlpha" behaviorConfiguration=" my.service.behavior ">

Yeah, finally... got the solution for this. 是的,终于......得到了解决方案。 My friend (network big boss :) ) told me how port communication works... Idea was simple: "check once again server and client firewall ports", and here is that point "client firewall". 我的朋友(网络大老板:))告诉我端口通信是如何工作的......想法很简单:“再次检查服务器和客户端防火墙端口”,这就是“客户端防火墙”。

I allowed only server firewall ports, but there should be allowed communication for client. 我只允许服务器防火墙端口,但应允许客户端进行通信。 Added TCP/UDP Outbound rule in client PC and it works magically. 在客户端PC中添加了TCP / UDP出站规则,它神奇地工作。

... and for UDP I needed to change TTL (default is 1). ...对于UDP,我需要更改TTL(默认值为1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM