位于“地址”的HTTP服务太忙了

时间:2012-08-10 20:47:31

标签: c# wcf

我正在使用WCF连续地将图像从服务器流式传输到客户端。但是,每当我尝试运行它时,我总是会收到此错误:

  

位于“本地主机地址”的HTTP服务太忙了。

我在网上到处寻找其他解决方案。我尝试过限制,增加缓冲区大小,并改变传输模式无济于事。我对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();
    }
}

3 个答案:

答案 0 :(得分:2)

我遇到了同样的问题......问题是链接到运行我的服务的应用程序池的帐户密码已更改。

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

答案 1 :(得分:0)

你说你是“不断”流式传输图像,这是否意味着你在循环中这样做?


更新: 我建议您打开WCF跟踪以帮助确定问题。请在此处查看此信息:

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

此外,您在服务方法和界面上定义了哪些服务属性?

答案 2 :(得分:-1)

想出来。我将端口号从8002更改为8003并且有效。不知道为什么,但只要它有效,我就不在乎。