WCF net.tcp 서비스를 작성하고 Net.Tcp Listener Adapter를 사용하여 호스트하면 훌륭하게 작동합니다. 서비스가 클라이언트를 상태로 업데이트 할 수 있도록 콜백합니다. 지금, 나는 Windows 서비스를 통해 호스트되는 의해 작동하도록 얻으려고하고, 내가 뭘 모두 원래 사용하는 것과 같은 클래스를 사용하여 ServiceHost를 만들 수 있습니다 :net.tcp 서비스는 Net.Tcp Listener Adapter에서 호스팅 할 때 작동하지만 Windows 서비스는 작동하지 않습니다.
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceProcess;
using BuilderService;
namespace BuilderWindowsService
{
public class BuilderWindowsService : ServiceBase
{
public ServiceHost ServiceHost = null;
public BuilderWindowsService()
{
ServiceName = ServiceNames.Builder;
}
public static void Main()
{
Run(new BuilderWindowsService());
}
protected override void OnStart(string[] args)
{
if (ServiceHost != null)
ServiceHost.Close();
ServiceHost = new ServiceHost(typeof(Builder));
ServiceHost.Open();
}
protected override void OnStop()
{
if(ServiceHost != null)
{
ServiceHost.Close();
ServiceHost = null;
}
}
}
}
내가 연결할 수 있습니다 서비스를 요청하고 요청을 보내지 만 응답하거나 시간 초과되지 않습니다. 나는 다른 포트 (8002)에 Windows 서비스가 있기 때문에 Windows 서비스를 사용하고 있다는 것을 알고 있으며이를 사용하여 참조로 추가 할 수 있습니다.
Windows 서비스 용 My App.config는 원본 Web.config와 거의 동일합니다. 808 대신 8002 끝점을 가리키는 것을 제외하고 내가 사용하고있는 클라이언트와 똑같은 기능을합니다. 또한 동일한 서비스를 위해 이미 동일한 서비스를 사용하고 있습니다. 그러나 어떤 이유로이 서비스가 응답하지 않습니다. UPDATE
내가 직접 간섭하는 것을 배제하기 위해 Windows 서비스를 타격 테스트하기 위해 약간의 클라이언트 응용 프로그램을 만들어, 그것은 다음의 app.config 생성 :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IBuilder"
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="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows"
algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8002/BuilderService/Builder.svc"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IBuilder"
contract="RGBRef.IBuilder"
name="NetTcpBinding_IBuilder">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
꽤 보인다 나에게 정상적인 (참고 : 나는 수동으로 버퍼/문자열 길이 값을 최대로 올렸다). 내 원래 설정과 다른 것만 :
transferMode="Buffered"
transactionProtocol="OleTransactions"
listenBacklog="10"
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
서비스에서 이러한 설정이 필요한지 잘 모릅니다. 어느 쪽이든, 그것은 여전히 어떤 응답이나 오류를 얻지 못합니다.
Windows 서비스에 로깅을 추가했지만 아무데도 오류가 발생하지 않습니다. –