当NServiceBus尝试安排超时时,Raven返回400“请求太长”错误

时间:2013-01-14 05:46:29

标签: ravendb nservicebus http-status-code-400

我有一个NServiceBus传奇,试图使用Raven超时持久性来安排超时,但是当它尝试时会出现此错误:

NServiceBus.Unicast.Transport.Transactional.TransactionalTransport [(null)] <(null)> - Failed raising 'transport message received' event for message with ID=90dadfbd-9eb6-4558-96ec-37edb642330a\17275422
    System.InvalidOperationException: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <HTML><HEAD><TITLE>Bad Request</TITLE>
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
    <BODY><h2>Bad Request - Request Too Long</h2>
    <hr><p>HTTP Error 400. The size of the request headers is too long.</p>
    </BODY></HTML>
     ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
       at System.Net.HttpWebRequest.GetResponse()
       at Raven.Client.Connection.HttpJsonRequest.ReadStringInternal(Func`1 getResponse)
       --- End of inner exception stack trace ---
       at Raven.Client.Connection.HttpJsonRequest.ReadStringInternal(Func`1 getResponse)
       at Raven.Client.Connection.HttpJsonRequest.ReadResponseString()
       at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson()
       at Raven.Client.Connection.ServerClient.DirectPut(RavenJObject metadata, String key, Nullable`1 etag, RavenJObject document, String operationUrl)
       at Raven.Client.Connection.ServerClient.<>c__DisplayClass10.<Put>b__f(String u)
       at Raven.Client.Connection.ServerClient.TryOperation[T](Func`2 operation, String operationUrl, Boolean avoidThrowing, T& result)
       at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func`2 operation)
       at Raven.Client.Connection.ServerClient.Put(String key, Nullable`1 etag, RavenJObject document, RavenJObject metadata)
       at Raven.Client.Document.HiLoKeyGenerator.PutDocument(JsonDocument document)
       at Raven.Client.Document.HiLoKeyGenerator.GetNextMax()
       at Raven.Client.Document.HiLoKeyGenerator.NextId()
       at Raven.Client.Document.HiLoKeyGenerator.GenerateDocumentKey(DocumentConvention convention, Object entity)
       at Raven.Client.Document.MultiTypeHiLoKeyGenerator.GenerateDocumentKey(DocumentConvention conventions, Object entity)
       at Raven.Client.Document.DocumentStore.<>c__DisplayClass1.<Initialize>b__0(Object entity)
       at Raven.Client.Document.InMemoryDocumentSessionOperations.GetOrGenerateDocumentKey(Object entity)
       at Raven.Client.Document.InMemoryDocumentSessionOperations.StoreInternal(Object entity, Nullable`1 etag, String id)
       at Raven.Client.Document.InMemoryDocumentSessionOperations.Store(Object entity)
       at NServiceBus.Timeout.Hosting.Windows.Persistence.RavenTimeoutPersistence.Add(TimeoutData timeout)
       at NServiceBus.Timeout.Core.TimeoutTransportMessageHandler.Handle(TransportMessage message)
       at NServiceBus.Unicast.Transport.Transactional.TransactionalTransport.OnTransportMessageReceived(TransportMessage msg)

我已经重启了Raven服务&amp; nservicebus主机。我已经尝试重新创建这个传奇但它仍然会发生。

正在安排的超时状态消息很小:

<Messages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.net/Invoicing.Service">
    <IPartPaymentTimeout>
        <Amount>10.00</Amount>
        <OriginalTransactionTimeUtc>2013-01-14T05:49:04.8180938Z</OriginalTransactionTimeUtc>
        <PaymentNumber>7</PaymentNumber>
        <Id>123456</Id>
        <InvoiceNumber>1234567/34567</InvoiceNumber>
    </IPartPaymentTimeout>
</Messages>

1 个答案:

答案 0 :(得分:3)

在我的案例中,通过停止自定义应用程序的新Relic来解决这个问题。看起来New Relic中有一个错误,它附加了一个请求标头X-NewRelic-ID,它会附加相同的数据,直到它长得太长:

X-NewRelic-ID: <hash>, <samehash>, <samehash>,.....<samehash>

禁用NewRelic.xml文件中的NServiceBus.Host检测可防止发送标头。

在NewRelic.xml中,您也可以禁用crossApplicationTracingEnabled

要检测此问题,请使用System.Diagnostics中的跟踪:

  <system.diagnostics>
<trace autoflush="true" />
<sources>
  <source name="System.Net" maxdatasize="1024">
    <listeners>
      <add name="MyTraceFile"/>
    </listeners>
  </source>
</sources>

<sharedListeners>
  <add
    name="MyTraceFile"
    type="System.Diagnostics.TextWriterTraceListener"
    initializeData="System.Net.trace.log"
            />
</sharedListeners>

<switches>
  <add name="System.Net" value="Verbose" />
</switches>