我在Azure中有一个具有2个部署插槽的Web应用程序。一个插槽用于开发目的;另一个插槽用于生产目的。在Azure生产槽位时SignalR间歇性停止
我已将SignalR hub(自我托管)放入我的一个控制器中。基本上这个控制器所做的是它负责将记录记录到我的Azure数据库中。特别是,该控制器用于控制用户何时在特定链接上打开和发送电子邮件和/或点击。
SignalR集线器用于简化向所有“连接用户”发送推送通知。
当我在我的开发槽上进行测试时,一切按预期工作。
但是,只要我将其交换到我的生产插槽;奇怪的行为开始发生。有一些通知来了;有些不(基本上不会到达客户端);或者通知来得晚。
现在我不知道如何解决这个问题。我不明白我的代码是否有任何错误(或者我正在做一些根本性的错误)。
我需要一些帮助,为什么这个事情间歇性地停止;或者似乎不起作用。
一个重要的说明......我还将WebSockets启用到了我的两个部署插槽中。
另外;消费者是WinForm客户端。
现在,这是我实际上向下发送该消息(推送通知到相应的ConnectionId):
AddToTblEmailEventDB(SentEmail, true, strEventOpen, strRecipientCookie);
//Save is done in this function
string strBody = Helper.HtmlHelper.OpenJsonSerializer(SentEmail);
List<string> lstConnectionIDsToSendTo = new List<string>();
if (UserHandler.ConnectedUsers != null)
{
for (int i = 0; i < UserHandler.ConnectedUsers.Count; i++)
{
if (UserHandler.ConnectedUsers.ElementAt(i).EmailAddress == SentEmail.tbl1Merges.AspNetUser.Email.ToString())
{
lstConnectionIDsToSendTo.Add(UserHandler.ConnectedUsers.ElementAt(i).ConnectionID);
}
}
}
//Actual Sending down happens here below....
if (lstConnectionIDsToSendTo.Count > 0)
{
for (int i = 0; i < lstConnectionIDsToSendTo.Count; i++)
{
//Start sending the messages down to the devices
hubContext.Clients.Client(lstConnectionIDsToSendTo.ElementAt(i)).updateMessages(strBody);
}
}
现在,这是基本上使用该消息(其在JSON格式)的代码客户端:
HubProxy.On(Of String)("updateMessages", Sub(message)
Me.Invoke(DirectCast(
Sub()
If DateTime.Now < dtmHideNotification Then
Exit Sub
End If
strJSONData = message
'Display
If strJSONData <> String.Empty Then
strJSONData = "[" & strJSONData & "]"
strJSONData = strJSONData.Replace(JSON_QUOTE, """") '"
dvNotifications = GetNotifications(strJSONData)
If dvNotifications IsNot Nothing Then
strSubject = dvNotifications(0).Item("Subject")
strType = Trim(dvNotifications(0).Item("Type"))
strDateTime = (dvNotifications(0).Item("Date"))
strRecipient = dvNotifications(0).Item("Recipients")
strEmailSendID = Trim(dvNotifications(0).Item("EmailSendID"))
If dvNotifications.Table.Columns("LinkClicked") IsNot Nothing Then
strLinkClicked = CStr(dvNotifications(0).Item("LinkClicked"))
Else
strLinkClicked = String.Empty
End If
If CInt(strRecipient) = 1 Then
strRecipient = dvNotifications(0).Item("EmailAddress")
Else
'strRecipient = "Someone"
'Dutt 7/12/15 Instead of someone , displaying "RecipientName or .."
strRecipient = dvNotifications(0).Item("EmailAddress") & " or..."
End If
If (strLinkClicked.Length > 20) Then
strLinkClicked = strLinkClicked.Substring(0, 20) & "..."
End If
Select Case strType
Case "O"
strType = "Opened"
Case "C"
strType = "Clicked"
Case "M"
Exit Sub 'If there is a Merge taking place, then need to skip this iteration of the loop (because we don't want to show it)
Case Else
'Do nothing Keep as same
End Select
Dim CustomNotification As New CustomNotification
CustomNotification.TopMost = False
CustomNotification.lblSubject.Text = IIf(strSubject = String.Empty, "[No Subject]", strSubject)
CustomNotification.EmailSendID = strEmailSendID
CustomNotification.pctIcon.Visible = True
CustomNotification.UserName = GetUserEmail()
CustomNotification.Password = GetUserPassword()
If strType <> String.Empty Then
If Trim(strType) = "Opened" Then
CustomNotification.pctBox.Image = My.Resources.glyphicons_52_eye_open
CustomNotification.lblContent.Text = strRecipient & " has " & strType.ToLower() & " this " & strDateTime
End If
If Trim(strType) = "Clicked" Then
CustomNotification.pctBox.Image = My.Resources.glyphicons_51_link
CustomNotification.lblContent.Text = strRecipient & " has clicked on" & " " & strLinkClicked & " " & strDateTime
End If
End If
CustomNotification.ShowDialog()
If CustomNotification.CloseTemporarily Then
If CustomNotification.CloseTemporarily Then
'Hide the form
CustomNotification.Close()
dtmHideNotification = DateTime.Now.AddMinutes(2)
Exit Sub
End If
End If
'Next
End If
End If
End Sub, Action))
End Sub)
请注意,WinForm使用者是VB.NET表单;并且它连接到集线器,等待任何消息被发送。
我不知道这是哪里出错了!
我以前没有遇到过这个ARR亲和力问题。但我现在就试一试。 –
确保从浏览器中删除ARRAffinity cookie,并关闭两个部署中的ARR Affinity,然后进行测试。 – Guy
现在只需在开发插槽上测试这一点....我似乎正在推动现在....不能太确定。稍后将交换确认。 –