信号R "No Connection with that ID"
SignalR "No Connection with that ID"
我有一个 asp.net 核心 2.1 网络应用程序,它作为独立应用程序部署到 Ubuntu 18.04 LAMP 服务器。
有一个聊天页面,使用 SignalR 创建,在本地主机上一切正常。
然而,当我连接到http://www.limboworld.net/real website/
然后转到聊天页面并使用开发人员工具检查控制台我看到以下内容:
https://drive.google.com/open?id=12JxhgoDtpXwrMFX7Z5oJ6MlkpkuN0How
当点击 link http://www.limboworld.net/hubs/chat?id=8rE5uw4Ck9PIpoaCF_KuMA 我得到 "No Connection with that ID".
根据 http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html,我尝试添加
ProxyPass "/ws2/" "ws://echo.websocket.org/"
指令,但我不确定是什么原因导致了问题。
也许我的代码有问题,这就是为什么我在这里发布这个的原因,即使我只尝试配置 Apache。
有人可以帮我删除 Chrome 开发人员工具控制台中的错误消息吗?
感谢任何关于为什么这不起作用的帮助。
正如我在上面的评论中所说,根据link更改apache配置后:https://community.bitwarden.com/t/websocket-fails-behind-apache-proxy/3696/3,如下:
<VirtualHost *:80>
RewriteEngine On
ProxyPreserveHost On
ProxyRequests Off
# allow for upgrading to websockets
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:5000/ [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://127.0.0.1:5000/ [P,L]
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ProxyPass /hubs/chat ws://127.0.0.1:5000/hubs/chat
ProxyPassReverse /hubs/chat ws://127.0.0.1:5000/hubs/chat
</VirtualHost>
浏览器正在连接到 websocket。
现在我有一个不同的错误:signalr.min.js:13 Error: Connection disconnected with error 'Error: Websocket closed with status code: 1006 ()'.
这篇文章:http://blog.etrupja.com/2018/08/the-antiforgery-token-could-not-be-decrypted/帮我解决了问题。
我必须使用命令 Install-Package Serilog.Extensions.Logging.File
安装 nuget 包,然后
将以下代码添加到 Startup.cs 文件:
ConfigureServices(IServiceCollection services)
{
//your code here
services.AddDataProtection()
.SetApplicationName("your-app-name")
.PersistKeysToFileSystem(new DirectoryInfo("your-path-here"));
//your code here
}
这有效地消除了 Chrome 开发人员工具控制台中的所有错误。
我希望这对遇到类似问题的人有所帮助。
干杯!
我有一个 asp.net 核心 2.1 网络应用程序,它作为独立应用程序部署到 Ubuntu 18.04 LAMP 服务器。
有一个聊天页面,使用 SignalR 创建,在本地主机上一切正常。
然而,当我连接到http://www.limboworld.net/real website/ 然后转到聊天页面并使用开发人员工具检查控制台我看到以下内容:
https://drive.google.com/open?id=12JxhgoDtpXwrMFX7Z5oJ6MlkpkuN0How
当点击 link http://www.limboworld.net/hubs/chat?id=8rE5uw4Ck9PIpoaCF_KuMA 我得到 "No Connection with that ID".
根据 http://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html,我尝试添加
ProxyPass "/ws2/" "ws://echo.websocket.org/"
指令,但我不确定是什么原因导致了问题。
也许我的代码有问题,这就是为什么我在这里发布这个的原因,即使我只尝试配置 Apache。
有人可以帮我删除 Chrome 开发人员工具控制台中的错误消息吗?
感谢任何关于为什么这不起作用的帮助。
正如我在上面的评论中所说,根据link更改apache配置后:https://community.bitwarden.com/t/websocket-fails-behind-apache-proxy/3696/3,如下:
<VirtualHost *:80>
RewriteEngine On
ProxyPreserveHost On
ProxyRequests Off
# allow for upgrading to websockets
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:5000/ [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://127.0.0.1:5000/ [P,L]
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ProxyPass /hubs/chat ws://127.0.0.1:5000/hubs/chat
ProxyPassReverse /hubs/chat ws://127.0.0.1:5000/hubs/chat
</VirtualHost>
浏览器正在连接到 websocket。
现在我有一个不同的错误:signalr.min.js:13 Error: Connection disconnected with error 'Error: Websocket closed with status code: 1006 ()'.
这篇文章:http://blog.etrupja.com/2018/08/the-antiforgery-token-could-not-be-decrypted/帮我解决了问题。
我必须使用命令 Install-Package Serilog.Extensions.Logging.File
安装 nuget 包,然后
将以下代码添加到 Startup.cs 文件:
ConfigureServices(IServiceCollection services)
{
//your code here
services.AddDataProtection()
.SetApplicationName("your-app-name")
.PersistKeysToFileSystem(new DirectoryInfo("your-path-here"));
//your code here
}
这有效地消除了 Chrome 开发人员工具控制台中的所有错误。
我希望这对遇到类似问题的人有所帮助。
干杯!