2012-08-10 47 views
2

我正在使用WCF不断将图像从服务器传输到客户端。然而,每当我尝试运行它,我总是得到这个错误:位于“地址”的HTTP服务太忙

The HTTP service located at "local host address here" is too busy.

我在网上无处不在,并尝试其他解决方案。我已经尝试调节,增加缓冲区大小,并改变传输模式无济于事。我对WCF很陌生,不知道要去哪里。如果有人有任何想法如何摆脱这个错误,我将不胜感激。谢谢!这是我所有的代码。

的app.config:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_VisionWcfInterface" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     <serviceThrottling maxConcurrentCalls="16" maxConcurrentInstances="2147483647" maxConcurrentSessions="10"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <client> 
     <endpoint address="http://localhost:8002/Visual/service" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_VisionWcfInterface" 
      contract="VisionWcfInterface" name="BasicHttpBinding_VisionWcfInterface" /> 
    </client> 
</system.serviceModel> 
</configuration> 

Client.cs文件和ClientWCF功能:

public Form1() 
{ 
    private VisionWcfClient client = new VisionWcfClient(); 
    client.Connect(); 
    pictureBox2.Image = ConvertByteArrayToImage(client.GetVideoStream()); 
} 

public byte[] GetVideoStream() 
{ 
    return m_clientProxy.GetVideoStream(); 
} 

Server.cs文件和ServerWCF功能:

public byte[] GetVideoStream() 
{ 
    return GetVideoStreamEvent(); 
} 

byte[] ads_GetVideoStreamEvent() 
{ 
    IntPtr pointer; 

    m_Buffers.GetAddress(out pointer); 

    Bitmap b = new Bitmap(m_Buffers.Width, m_Buffers.Height, m_Buffers.Pitch, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, pointer); 
    System.Drawing.Imaging.ColorPalette palette = b.Palette; 
    Color[] entries = palette.Entries; 
    for (int i = 0; i < 256; i++) 
     entries[i] = Color.FromArgb(255, i, i, i); 

    b.Palette = palette; 
    m_Buffers.ReleaseAddress(pointer); 
    using (MemoryStream ms = new MemoryStream()) 
    { 
     b.Save(ms, ImageFormat.Bmp); 
     return ms.ToArray(); 
    } 
} 

回答

-1

想通了。我将端口号从8002更改为8003,它工作。不知道为什么,但只要它有效,我不在乎。

0

你说你是“连续”流式传输图像,这是否意味着您正在循环播放?


更新: 我建议你打开WCF跟踪,以帮助确定问题。看到这个信息在这里:

http://msdn.microsoft.com/en-us/library/ms733025.aspx

此外,什么是服务属性,你有你的服务方法和接口定义的?

+0

最终我会,但我现在至少想要得到一张图片。如果我这样做,最终会遇到问题吗? – 2012-08-10 21:32:03

+0

不,我刚才注意到你的描述和代码之间的不一致,并且认为你可能有太多的并发连接。你将不得不改变配置,以允许你想要的同时连接的数量(我忘记了多少默认值),但这不应该是你的问题。 – ExcaliburVT 2012-08-10 21:35:28

+0

这是一个非常愚蠢的问题,但就像我之前提到的,我是新的。那么服务标题是什么意思? – 2012-08-10 21:49:13

2

我遇到了同样的问题...问题在于,连接到运行我的服务的应用程序池的帐户更改了其密码。

将AppPool与有效凭证相关联后,服务开始再次正常运行。

+1

太棒了回答,为我工作。谢谢! – schlingel 2015-02-17 13:18:07