1

我正在尝试托管具有以下属性的 wcf 服务;

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]

我正在创建这样的主机类;

    var uri = new Uri("net.tcp://localhost:7951");
    var binding = new NetTcpBinding();
    host = new ServiceHost(typeof(ChatService), uri);
    ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
    if (smb == null) host.Description.Behaviors.Add(new ServiceMetadataBehavior());
    host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
    host.AddServiceEndpoint(typeof(IChat), new NetTcpBinding(), "");
    host.Open();

因此,在开发人员计算机和专用服务器上,这是可行的。但是,我需要做的是,将其托管在 VPS(虚拟专用服务器)上。

我想制作一个 Web 项目并将此代码块添加到 global.asax 应用程序启动方法中。但这失败了。我怀疑端口可能从防火墙关闭的问题。

我应该遵循什么解决方案?

4

0 回答 0