- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个网络应用程序,我在特定页面上使用两个集线器将通知从服务器推送到客户端并处理客户端之间的消息。但是,我在 Azure 生产应用服务中遇到了一种情况,其中通知中心不会将数据传输回客户端,即使查询带来了正确的数据。
客户端代码:
// Declare a proxy to reference the hub.
var notifHub = $.connection.NotificationHub;
var chat = $.connection.ChatHub;
var maxTabs = 10, index = 1;
// Start the connection.
$.connection.hub.start().done(function () {
notifHub.server.getNotifications();
/* Some more code irrelevant to this question */
});
notifHub.client.getNotifications = function (notification) {
// Html encode display name and message.
const notifications = JSON.parse(notification);
// Add the message to the page.
$("#Notifications").empty();
notifications.forEach(function (notification) {
const notificationDate = new Date(notification.CreationDate);
let alertColor = "";
if (((new Date) - notificationDate) < oneMinute)
alertColor = "alert-success";
else if (((new Date) - notificationDate) > oneMinute &&
((new Date) - notificationDate) < fiveMinutes)
alertColor = "alert-warning";
else if (((new Date) - notificationDate) > fiveMinutes)
alertColor = "alert-danger";
//language=html
var notificationTemplate = "<div class ='alert " + alertColor + "' role='alert' data-request-id='{{RequestId}}' data-connection-id='{{ConnectionId}}' data-requester='{{RequesterName}}' data-group-name='{{RequesterGroup}}' data-request-date-time='{{CreationDate}}'><strong>Usuario</strong>: {{RequesterName}}<br /><strong>Fecha</strong>: {{CreationDate | datetime}}</div>";
$("#Notifications").append(Mustache.render(notificationTemplate, notification));
});
};
中心代码
public void GetNotifications()
{
var db = new Entities();
db.Database.Log = s => Debug.WriteLine(s);
var companyId = Context.User.Identity.GetCompanyId();
var notifications = (from notification in db.AgentRequestNotification
where notification.AttendedByAgent == false && notification.CompanyId == companyId
orderby notification.CreationDate
select notification).ToList();
Clients.All.getNotifications(JsonConvert.SerializeObject(notifications));
}
代码在我的本地环境中完美运行,如下面的屏幕截图所示
但不适用于生产环境
在我的 Azure 应用程序设置中,我启用了 Websockets 并禁用了 ARR Affinity。我有使用 VS 远程调试,这是我得到的输出,不确定 EF 查询日志后显示的 WebSocketException 的原因是什么
Opened connection at 1/15/2018 9:03:46 PM +00:00
SELECT
[Project1].[RequestId] AS [RequestId],
[Project1].[ConnectionId] AS [ConnectionId],
[Project1].[RequesterName] AS [RequesterName],
[Project1].[RequesterGroup] AS [RequesterGroup],
[Project1].[AttendedByAgent] AS [AttendedByAgent],
[Project1].[CreationDate] AS [CreationDate],
[Project1].[CompanyId] AS [CompanyId],
[Project1].[AttendedByAgentDate] AS [AttendedByAgentDate]
FROM ( SELECT
[Extent1].[RequestId] AS [RequestId],
[Extent1].[ConnectionId] AS [ConnectionId],
[Extent1].[RequesterName] AS [RequesterName],
[Extent1].[RequesterGroup] AS [RequesterGroup],
[Extent1].[AttendedByAgent] AS [AttendedByAgent],
[Extent1].[CreationDate] AS [CreationDate],
[Extent1].[CompanyId] AS [CompanyId],
[Extent1].[AttendedByAgentDate] AS [AttendedByAgentDate]
FROM [dbo].[AgentRequestNotification] AS [Extent1]
WHERE (0 = [Extent1].[AttendedByAgent]) AND ([Extent1].[CompanyId] = @p__linq__0)
) AS [Project1]
ORDER BY [Project1].[CreationDate] ASC
-- p__linq__0: '1' (Type = Int32, IsNullable = false)
-- Executing at 1/15/2018 9:03:49 PM +00:00
-- Completed in 25 ms with result: SqlDataReader
Closed connection at 1/15/2018 9:03:49 PM +00:00
The thread 0x1520 has exited with code 0 (0x0).
The thread 0x2904 has exited with code 0 (0x0).
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in System.Web.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in System.Web.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in mscorlib.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Net.WebSockets.WebSocketException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
w3wp.exe Error: 0 : Error while closing the websocket: System.Net.WebSockets.WebSocketException (0x800704CD): An operation was attempted on a nonexistent network connection
at System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass8_0.<WriteCloseFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass46_0.<<DoWork>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<DoWork>d__45`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass32_0.<<CloseOutputAsyncImpl>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<>c.<<CloseAsync>b__13_0>d.MoveNext()
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in EntityFramework.SqlServer.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in Microsoft.Owin.Security.Cookies.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in mscorlib.dll
Exception thrown: 'System.Data.Entity.Core.EntityCommandExecutionException' in Microsoft.Owin.Host.SystemWeb.dll
The thread 0x219c has exited with code 0 (0x0).
这是 SignalR 客户端日志
[17:56:53 GMT-0500 (Eastern Standard Time)] SignalR: No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.
[17:56:53 GMT-0500 (Eastern Standard Time)] ignalR: Negotiating with '/signalr/negotiate? clientProtocol=1.5&connectionData=%5B%5D'.
[17:56:53 GMT-0500 (Eastern Standard Time)] SignalR: webSockets transport starting.
[17:56:53 GMT-0500 (Eastern Standard Time)] SignalR: Connecting to websocket endpoint 'ws://samiweb.azurewebsites.net/signalr/connect? transport=webSockets&clientProtocol=1.5&connectionToken=yKn2ns1bOenZLiUtCiOSSfQg YCl%2FyVAvxKejSZx2x0svkyzIJJ85qjNMk7IBjy8Nes0Lg9W%2BUTAPW21z6rVHTwXbb4wxaZhVwn1J vzrNra0WhYCuXMiu6kLYs0FWuRUy&connectionData=%5B%5D&tid=1'.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Websocket opened.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: webSockets transport connected. Initiating start request.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332, keep alive timeout of 20000 and disconnecting timeout of 30000
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Invoking saminotificationhub.GetNotifications
[17:56:54 GMT-0500 (Eastern Standard Time)] SignalR: Invoked saminotificationhub.GetNotifications
任何帮助将不胜感激!
最佳答案
来自您的 SignalR 客户端日志:
No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.
据我所知,正常的客户端日志如下所示:客户端订阅了集线器“notificationhub”
。您可以尝试在 $.connection.hub.start()
之前声明您的客户端方法。
关于c# - Signalr 未在 Azure 主机上发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48274367/
我在这里想做的是将所有连接转发到机器一上端口 3306 上的本地主机到本地主机上端口 3306 上的机器二。因此,如果您连接到机器一上的 mysql,它的行为就像您正在连接一样在二号机器上。 我认为
通过Kibana界面,如何获得 flex IP /主机? 我的意思是,与kibana连接的Elastic主机。 那有可能吗?我在这个上挣扎了好几个小时,却一无所获:( 附:不确定此问题是否是题外话,应
我知道这听起来很奇怪,但我有一个情况,Deno 需要关闭自己的主机(并因此杀死自己的进程)。这可能吗? 我特别需要这个用于 linux (lubuntu),如果相关的话。我想这需要 sudo 权限,这
我知道这听起来很奇怪,但我有一个情况,Deno 需要关闭自己的主机(并因此杀死自己的进程)。这可能吗? 我特别需要这个用于 linux (lubuntu),如果相关的话。我想这需要 sudo 权限,这
我有一个基本问题,但谷歌并没有为我产生很多结果(反正不是英文的)。基本上我想做的就是: 我有一个图形需要用作整个应用程序的持久 header ,例如:我不能让它在新的 Intent 调用时从屏幕上滑出
您好,我正在使用 xampp,我正在尝试使用 php 进行连接。 $sql_connections = mysql_connect("$server, $username, $password")
我目前正在尝试一些多人游戏的想法,并正在尝试创建一个 Java 应用程序来为基于网络浏览器的多人游戏提供服务。 我的开发环境是主机上的Eclipse, native 上的notepad + Googl
今天为大家分享一篇关于SSH 的介绍和使用方法的文章。本文从SSH是什么出发,讲述了SSH的基本用法,之后在远程登录、端口转发等多种场景下进行独立的讲述,希望能对大家有所帮助。 什么是SSH?
我已经完成了在裸机 Centos 7 上运行的测试 Kubernets 主机的设置。这将用作测试系统,因为我们将在 IBM Bluemix Kubernetes 服务中部署所有内容。 从 Bluemi
我正在尝试通过带有 4.2(果冻 bean )的 android 设备“nexus 7”通过 USB 与我的 freeduino 板进行通信,该板类似于 arduino uno。 几个月后,我使用开发
我正在使用 nginx,但在设置反向代理时遇到问题。 我的 nginx.conf 是默认的(没有对其进行任何更改),我的站点可用配置是: upstream backend_hosts { se
我在 projectlocker(免费 svn 主机)上有一个帐户,但我不知道如何将我的项目文件上传到它。 我在我的仪表板中找不到任何选项。 我在我的电脑上使用tortoiseSvn,那么如何上传文件
设置batchSize = 1有意义吗?如果我想一次处理一个文件? 尝试过batchSize = 1000和batchSize = 1 - 似乎具有相同的效果 { "version": "2.0"
我只想知道.. docker中现在有任何可用的工具吗?我已经阅读了Docker中有关多主机功能的一些文档,例如, Docker群 Docker服务(带有副本) 我也知道群模式下的volume问题,容器
我想将文件从 Docker 的容器挂载到我的 docker 主机。 数据卷不是我的解决方案,因为它们是从 docker 主机到 docker 容器的装载,我需要相反的方法。 谢谢 最佳答案 当 doc
我是新手。我无法正确理解RMI。互联网上有大量教程,但据我所知,它们都是针对本地主机的。服务器和客户端都运行在同一台机器上。 我想在任何计算机上运行客户端,并且主机将位于一台计算机上,让我们考虑IP
我无法从客户端“A”SSH 到服务器“B”(但我可以从同一子网上的许多其他 ssh 客户端而不是“A”——所有都是 *nux 机器) serverA>ssh -v -p 端口用户@serverB Op
设置batchSize = 1有意义吗?如果我想一次处理一个文件? 尝试过batchSize = 1000和batchSize = 1 - 似乎具有相同的效果 { "version": "2.0"
由于我不是天生的编码员,请多多包涵。 这是我尝试使用HAproxy来实现的目标,但是经过数小时的检查后,我无法以某种方式使其工作。 从 domain.com/alpha domain.com/beta
我正在使用 tomcat 运行 Java Web 应用程序,通过电子邮件将生成的报告发送给用户。我可以发送电子邮件,但几个小时后服务器停止发送电子邮件,并出现以下错误。 javax.mail.Mess
我是一名优秀的程序员,十分优秀!