2016-04-01 17 views
11

SinyalR ile ilgili bir sorun yaşıyoruz. Gerçek zamanlı teklifler için signalr üzerinde çalışan bir açık artırma sitemiz var. Bazı sorunları tarayıcıyla düzelttik ve her şey iyi çalışıyor gibi görünüyordu. Ardından sunucumuza yeni bir kalıntı yerleştirdik ve her dakika sinyalr bağlantısında http hata kodu 400'ü aldığımızı, yeniden bağlanıp iptal ettiğimizi fark ettik. Burada bir ekran görüntüsü var:SinyalR neden bozuk istek 400 sunucuda görüldü

New Relic Data

SignalR bağlamak ve yeniden yeni kalıntı göre sitenin operasyonlarını en çok zaman vardır.

javascript istemci şöyle
public class SignalRHub : Hub 
{ 
    public void BroadCastMessage(String msg) 
    { 
     var hubContext = GlobalHost.ConnectionManager.GetHubContext<SignalRHub>(); 

     hubContext.Clients.All.receiveMessage(msg); 
    } 
} 

public partial class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     string appString=string.Empty; 

     //Gets the connection string. 
     if (System.Configuration.ConfigurationSettings.AppSettings["SignaRScaleoutConn"] != null) 
     { 
      appString = System.Configuration.ConfigurationSettings.AppSettings["SignaRScaleoutConn"].ToString(); 
     } 

     GlobalHost.DependencyResolver.UseSqlServer(appString); 
     GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromMinutes(15); //I added this timeout, but it is not required. 
     app.MapSignalR(); 
    } 
} 

, bu uzun, ama bunun çoğu DOM etkileyecek jQuery olduğunu, bunu şunlardır: Burada

(Biz signalr arka yüzü olarak sql sunucusu kullanmak) SignalR arka uç kodudur tüm bunların içinde bir şey yanlış olabilir.
$(function() { 

      var chatProxy = $.connection.signalRHub; 

      $.connection.hub.start(); 

      chatProxy.client.receiveMessage = function (msg) { 

       var all = $(".soon").map(function() { 

        var hiddenModelId = $("#hiddenListingId"); 

        if (msg == hiddenModelId.val()) { 

         $.ajax({ 
          async: "true", 
          url: "/Listing/AuctionRemainingTime", 
          type: "POST", 
          dataType: 'json', 
          data: '{ "listingID": "' + msg + '"}', 
          contentType: "application/json; charset=utf-8", 
          success: function (data) { 
           if (data != null) { 

            SoonSettings.HasReloadedThisTick = false; 

            var element = document.getElementById(msg); 

            var obj = JSON.parse(data) 

            // For Clock Counter End Date Time Interval 
            // Adds 2 minutes to the soon clock when bid is close to finishing. 
            var hdID = "hdn" + obj.ListingId; 
            var hdValue = $("#" + hdID); 
            if (obj.EndDate != hdValue.val()) { 

             SoonSettings.HasUpdated = false; //Allows clock to change color once it gets under two minutes. 

             $('#' + hdID).val(obj.EndDate); 
             Soon.destroy(element); 
             Soon.create(element, { //Recreates clock with the before 2 minute tick event. 
              'due': 'in ' + obj.Seconds + ' seconds', 
              'layout':'group label-uppercase', 
              'visual':'ring cap-round progressgradient-00fff6_075fff ring-width-custom gap-0', 
              'face':'text', 
              'eventTick': 'tick' 
             }); 
            } 

            var highbid = obj.HighBidderURL; 

            // For Date Ends Info. 
            var ListingEndDate = $("#tdAuctionListingEndDate"); 

            if (obj.EndDate != ListingEndDate.val()) { 
             $('#' + hdID).val(obj.EndDate); 
             ListingEndDate.text(obj.EndDate + " Eastern"); 
             ListingEndDate.effect("pulsate", { times: 5 }, 5000); 
            } 
            else 
            { 
             $(".Bidding_Current_Price").stop(true, true); ///Removes the pulsating effect. 
             $(".Bidding_Current_Price").removeAttr("style"); //Removes unnecessary attribute from HTML. 
            } 

            //Bid div notification. 
            if (obj.AcceptedActionCount.replace(/[^:]+:*/, "") > 0) { 

             if (obj.Disposition != '' && obj.Disposition != null) { 
              if (obj.Disposition == "Neutral") { 
               $("#spanNeutralBid").show(); 
               $("#divOutbidNotification").hide(); 
               $("#spanPositiveBid").hide(); 
               $("#divProxyBidNotification").hide(); 
              } 
              else if (obj.Disposition == "Positive") { 
               $("#spanPositiveBid").show(); 
               $("#divOutbidNotification").hide(); 
               $("#spanNeutralBid").hide(); 
               $("#divProxyBidNotification").hide(); 
              } 
              else if (obj.Disposition == "Negative") { 
               $("#divOutbidNotification").show(); 
               $("#spanNeutralBid").hide(); 
               $("#spanPositiveBid").hide(); 
               $("#divProxyBidNotification").hide(); 
              } 
              else { 
               $("#divOutbidNotification").hide(); 
               $("#spanNeutralBid").hide(); 
               $("#divProxyBidNotification").hide(); 
               $("#spanPositiveBid").hide();  
              } 

             } 
            } 

            // For Highlight Current Price when it is Updated 
            var hdCurrentPrice = $("#hdnCurrentPrice"); 

            if (obj.CurrentPrice != hdCurrentPrice.val()) { 

             $(".Bidding_Current_Price").text(obj.CurrentPrice); 
             $(".Bidding_Current_Price").effect("pulsate", { times: 5 }, 5000); 
             $("#hdnCurrentPrice").val(obj.CurrentPrice); 
            } 
            else { 
             $(".Bidding_Current_Price").stop(true, true); 
             $(".Bidding_Current_Price").removeAttr("style"); 
            } 

            // For ReservePrice Status 
            $("#spanReservePriceStatus").html(obj.ReservePriceStatus); 
            $("#smallReservePriceStatus").html(obj.ReservePriceStatus); 

            // For Bid Count 

            var spanBidCounter = $("#spanBidCount"); 

            $(spanBidCounter).text(obj.AcceptedActionCount); 


            var stringAppend = "<tr id='trhHighBidder'><td><strong>HighBidder</strong></td>"; 
            stringAppend += "<td>"; 
            if (obj.isAdmin == true) { 
             stringAppend += "<a id='anchorHighBid' href=" + obj.HighBidderURL + ">"; 
             stringAppend += "<span id='spanHighBidder'>" + obj.CurrentListingActionUserName + "</span>" 
             stringAppend += "</a>"; 
            } 
            else { 
             stringAppend += "<span id='spanHighBidderAnonymous'>" + obj.CurrentListingActionUserName + "</span>"; 
            } 
            stringAppend += "</td></tr>"; 

            if (obj.AcceptedActionCount.replace(/[^:]+:*/, "") > 0) { 
             if ($("#tblAuctionDetail").find("#rowHighBidder").length > 0) { 

              if ($("#tblAuctionDetail").find("#trhHighBidder").length > 0) { 
               $("#trhHighBidder").remove(); 
              } 
             } 
             else { 

              //add tr to table 
              if (!$("#tblAuctionDetail").find("#trhHighBidder").length > 0) { 
               $('#tblAuctionDetail > tbody > tr:eq(6)').after(stringAppend); 
              } 
             } 
            } 

            // For High Bidder 

            if (obj.isAdmin) { 

             var anchorElement = $("#anchorHighBid"); 
             $(anchorElement).attr("href", obj.HighBidderURL); 

             var spanHighBidder = $("#spanHighBidder"); 
             $(spanHighBidder).text(obj.CurrentListingActionUserName); 
            } 
            else { 
             var spanAdminHighBid = $("#spanHighBidderAnonymous"); 
             $(spanAdminHighBid).text(obj.CurrentListingActionUserName) 
            } 

           } 
          }, 
          error: function (xhr, textStatus, errorThrown) { 

          } 
         }); 
        } 
       }); 
      }; 

     }); 

istemci veya çok sık oluyor bu hataları önlemek için değiştirilmesi gerekebilir sunucu signalr koduyla yanlış bir şey var mı? 400 kodu neredeyse her dakika gösterme eğilimindedir. Ben sinyal için çok yeni ve onunla etkili kod nasıl yapılacağını çok az biliyorum.

Sitede gerçek zamanlı teklif verme işe yarıyor, sadece bu sabit hataları önlemek için bir yol bulmak için. SignalR'nin nasıl çalıştığını açıklayan her türlü yardım takdir edilir. Ben SignalR ulaşım yöntemini değiştirmeyi deneyin verirdim

+2

Aynı zamanda hatalar da alıyoruz. Servicebus'u arka plan olarak kullanıyoruz. Arka plan ve yük dengeleyici ile ilgili olduğunu düşünüyorum. Yükleyici veya otomatik ölçeklendirme var mı? –

+0

Yük dengeleyicimiz var, ilginç. Bu konuya neden olan bir şey düşünmemiştim. –

+0

"Kötü İstek" yanıtının gövdesinde ne var? –

cevap

İlgili konular