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