Tôi có một dịch vụ WCF đơn giản tổ chức trong IIS7.5 tiếp xúc với hơn một wsHttp ràng buộc sử dụng bảo mật tin nhắn và InstanceContextMode.PerCallInstances WCF Max dường như bị giới hạn ở 10
Tôi có một giao diện người dùng đơn giản mà quay lên một số cấu hình các chủ đề, mỗi chủ đề gọi dịch vụ.
Tôi đã thêm bộ đếm dịch vụ hỗ trợ perfmonModel4.Instances. Bất kể số lượng các chủ đề được tạo ra và gọi dịch vụ, perfmon cho thấy dịch vụ tạo ra tối đa 10 Trường hợp.
cấu hình khách hàng của tôi là như sau:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService3">
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/NGCInstancing/Service3.svc/~/Service3.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService3"
contract="NGCSecPerCall.IService3" name="WSHttpBinding_IService3">
<identity>
<servicePrincipalName value="host/RB-T510" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
dịch vụ cấu hình của tôi là như sau:
<?xml version="1.0"?>
<system.serviceModel>
<configuration>
<behaviors>
<serviceBehaviors>
<behavior name="SecPerCallBehaviour">
<serviceThrottling maxConcurrentCalls="30" maxConcurrentSessions="1000"
maxConcurrentInstances="30" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="BindingMessageSecPerCall" >
<security mode="Message">
<!-- it's by setting establishSecurityContext to false that we enable per call instancing with security -->
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ServiceInstancingDemo.Service3" behaviorConfiguration="SecPerCallBehaviour">
<endpoint address="~/Service3.svc"
binding="wsHttpBinding" bindingConfiguration="BindingMessageSecPerCall"
contract="ServiceInstancingDemo.IService3" />
</service>
</services>
</configuration>
</system.serviceModel>
Mã khách hàng như sau:
private void btnSecPerCall_Click(object sender, EventArgs e)
{
int i;
int requests;
int delay;
lblStatus.Text = "";
DateTime startTime = DateTime.Now;
this.listBox1.Items.Add("start time=" + DateTime.Now);
delay = Convert.ToInt16(txtDelay.Text);
requests = Convert.ToInt16(txtRequests.Text);
Task<string>[] result;
result = new Task<string>[requests];
for (i = 0; i < requests; i++)
{
result[i] = Task<string>.Factory.StartNew(() => _ngcSecPerCall.WaitThenReturnString(delay));
}
for (i = 0; i < requests; i++)
{
this.listBox1.Items.Add(result[i].Result);
}
DateTime endTime = DateTime.Now;
TimeSpan ts = endTime - startTime;
lblStatus.Text = "Finished! Time taken= " + ts.Seconds + " seconds";
this.listBox1.Items.Add("end time=" + DateTime.Now);
}
mã dịch vụ của tôi là như sau:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class Service3 : IService3
{
private int m_counter;
public string WaitThenReturnString(int waitMilliSeconds)
{
System.Threading.Thread.Sleep(waitMilliSeconds);
int maxT, workCT;
System.Threading.ThreadPool.GetMaxThreads(out maxT, out workCT);
m_counter++;
return String.Format("Incrementing counter to {0}.\r\nSession Id: {1}. Threads {2}, {3}", m_counter, OperationContext.Current.SessionId, maxT, workCT);
}
}
Dịch vụ trả về 400,400 cho số lượng chủ đề.
Có ai biết tại sao dịch vụ từ chối tạo thêm 10 trường hợp đó không?
Nếu tôi tạo bản sao của dịch vụ nhưng với liên kết wsHttp có <security mode="None"/>
thì dịch vụ sẽ tạo ra nhiều trường hợp vui vẻ hơn.
Điều này nghe có vẻ đầy hứa hẹn! Tôi đang sử dụng Windows 7. Tôi sẽ triển khai một máy ảo win2008 vào ngày mai và quay trở lại. –
Vâng, đúng vậy. Khi tôi thử nghiệm trên máy ảo Win 2008 nó hoạt động rất tốt. Rất cám ơn Graymatter –