- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已在 azure 门户
中创建了 Azure SignalR(无服务器)资源
。然后,我在本地创建了一个引用 Microsoft.Azure.WebJobs.Extensions.SignalRService 的 Azure 函数 HttpTrigger。在我的azure函数
中,我有以下代码:
`public static class HttpTrigger
{
[FunctionName("Negotiate")]
public static SignalRConnectionInfo Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[SignalRConnectionInfo(HubName = "notificationHub")] SignalRConnectionInfo connectionInfo,
ILogger log)
{
log.LogInformation("Returning connection: " + connectionInfo.Url + "" + connectionInfo.AccessToken);
return connectionInfo;
}
[FunctionName("Notify")]
public static async Task<IActionResult> Notify([HttpTrigger(AuthorizationLevel.Function, "get", Route=null)] HttpRequest req,
[SignalR(HubName = "notificationHub")] IAsyncCollector<SignalRMessage> signalRMessage,
ILogger log)
{
log.LogInformation("Notify");
string msg = string.Format("Message from agent! {0} ", DateTime.Now);
await signalRMessage.AddAsync(
new SignalRMessage
{
Target = "notifications",
Arguments = new[] { msg }
});
return new OkObjectResult("ok");
}
}
`同样在我的 azure 函数中,这就是我的 local.settings.json 的样子:
`
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureSignalRConnectionString": "myconnstringhere"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "http://localhost:53377",
"CORSCredentials": true
}
}
为了解决 CORS 问题,我添加了客户端部分项目的 http://localhost:53377
域。
我的客户端部分是一个单独的 asp.net Web 应用程序项目
。所以在这里我像这样连接到这个azure函数:
`
<script>
$(document).ready(function(){
const connection = new signalR.HubConnectionBuilder()
.withUrl("http://localhost:7071/api/")
.configureLogging(signalR.LogLevel.Information)
.build();
connection.onclose(start);
start(connection);
});
async function start(connection){
try {
await connection.start();
console.log("SignalR connected.");
connection.on("notifications", (message) => {
$("#detailcontainer").html(message);
console.log(message)
});
}
catch(err) {
console.log(err);
}
}
</script>
现在,我已经发布了我的 azure 函数。但现在它不再起作用了。触发/api/negotiate 时出现未经授权的错误。
我的 azure 函数是 .net 6
项目,而客户端应用程序是 net Framework 4.8
。这是因为我的客户端应用程序仍在 webforms
中吗?
我已将我的 azure signalR 的连接字符串添加到应用程序设置中,其名称格式如下:Azure__SignalR__ConnectionString
我还为我的 azure 函数配置了 CORS 允许的来源,我添加了我的客户端本地主机应用程序。
最佳答案
关闭这个是因为我找到了答案。我错过了这个,这真的很烦人。
我将 AuthorizationLevel.Function
替换为 AuthorizationLevel.Anonymous
。因为我只是传递我的 azure 函数的域/api 并让 signalR 在它们的 JS 上执行其操作。
关于asp.net - Azure signalR + Azure http 触发器 - 部署时授权错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74373320/
我想知道如何存储在调用时可以触发到连接的客户端的变量服务器端? 我使用并发字典来跟踪连接 GUID 并想知道我是否可以在服务器上存储字符串或其他数据类型,例如最后 10 条消息,因此当出现新连接时,客
无法让 SignalR 在我的机器上工作(使用 IE9)。在输入一些文本并单击提交时,文本未按预期列出。另外,我希望从多个浏览器实例更新列表,但它不会发生。没有错误。有人可以帮忙吗? C# names
找到后this update围绕与组的通信,似乎一个组与集线器名称无关。如果这是正确的(如果我弄错了,请告诉我)集线器有什么方法可以访问另一个集线器的组,或者更好地拥有某种全局组? 我的问题是我有一个
抽象的 嗨,我在考虑是否可以使用 SignalR 发送消息。假设客户端断开连接,但最终在很短的时间内(例如 3 秒)重新连接。客户端会在断开连接时收到所有发送给他的消息吗? 例如,让我们考虑 Long
我正在为中等负载的 Web 应用程序评估 SignalR。 我们期望大约 500 条消息/秒,这对 SignalR 来说应该不是问题。 但是,我们担心此解决方案的可靠性。我们的环境有一个有问题的网络,
我有以下JS工作: var chat = $.connection.appHub; 我的应用程序有一个单一的中心AppHub,它处理两种类型的通知-Chat和Other。我使用一个集线器,因为我需要一
我升级到.NET 4.5,现在SignalR似乎坚持要在Firefox / Chrome中使用WebSockets-即使我只是在没有WebSocket Server的Windows 7上使用。 该请求
您能否在服务器端辨别给定的SignalR连接使用哪种传输方法? (WebSocket,SSE,长时间轮询等?) 最佳答案 在集线器内部,您可以通过查看请求的查询字符串来检测正在使用的传输: Conte
我在MVC4应用程序中使用Visual Studio 2012 Ultimate RC,SignalR 0.5.1和Jquery 1.7.2。 我看过:MVC4 SignalR "signalr/hu
假设我的网络连接中断了几秒钟,并且我错过了一些 SignalR 服务器推送的消息。 当我重新获得网络连接时,我错过的消息是否会丢失?或者当我重新连接时 signalR 会处理它们并将它们推出吗? 如果
如果我有一个 signalR 集线器,它向所有具有相当大的有效负载或私有(private)信息的客户端发送消息,那么所有连接到该集线器的客户端(同一组的一部分)是否都会收到消息,即使它们没有订阅客户端
如果我有一个 signalR 集线器,它向所有具有相当大的有效负载或私有(private)信息的客户端发送消息,那么所有连接到该集线器的客户端(同一组的一部分)是否都会收到消息,即使它们没有订阅客户端
谁能让我知道 SignalR 内部是如何以高级方式工作的? 我猜测它正在使用 Response.Flush 刷新数据,并且在客户端以一定的时间间隔发送 Ajax 请求。正确吗? 最佳答案 不,Sign
我正在使用 Microsoft SignalR 向浏览器推送通知。这些通知是由其他浏览器的操作触发的。我想做一个有时发送通知的后台任务。例如,在 12:45:21,我想向所有连接的用户发出通知,即使他
我的 SignalR 存在以下问题,用户从移动设备访问我的网站。 问题在于,当手机锁定或用户转到另一个应用程序时,会在服务器上触发 Disconnect() 方法(我尝试向服务器发送消息并等待它通过
如果我使用 SignalR 发送消息,客户端是否可能收不到消息?您如何验证通信中是否出现任何错误?我想在发送服务器通知后将消息发送回服务器,但有没有更好的方法? 最佳答案 是的,客户端可能没有收到消息
Web 服务器如何使用 SignalR 同步调用客户端上的方法?这里的关键部分是服务器应该等待客户端将数据发送回服务器才能继续? 基本上,我希望将客户端方法调用视为 WCF 服务请求。调用客户端并等待
我正在尝试调试 SignalR 连接问题,虽然我知道如何启用客户端日志记录,但我不知道如何启用服务器端日志记录。它似乎没有将任何内容记录到控制台。 我试过在 HubConfiguration 中使用
如果 SignalR 服务器的内部缓冲区溢出,则它似乎可以在将消息发送到客户端之前丢弃消息(请参阅 https://github.com/SignalR/SignalR/issues/2075 )。目
我在 Blazor 服务器端应用程序中使用 SignalR。我将 Microsoft.AspNetCore.SignalR.Client Nuget 包 (v5.0.11) 添加到项目中,并使用以下代
我是一名优秀的程序员,十分优秀!