Raspberry Pi 上的自托管 SignalR 可以工作吗? [英] Can self hosted SignalR on the Raspberry Pi work?

查看:19
本文介绍了Raspberry Pi 上的自托管 SignalR 可以工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Raspberry Pi 上托管一个基于 C#/mono/signalR 的网页 - 这可能吗?

I want to have a C#/mono/signalR based web page hosted on the Raspberry Pi - is this possible?

我设法编写了一个客户端-服务器-客户端解决方案,其中 signalR 集线器托管在运行 IIS 8 的 PC 上.pi 上的控制台应用程序使用 c# signalR 客户端连接到服务器集线器.asp.net 服务器还托管一个远程控制"页面,供浏览器客户端向 pi 发送命令,但现在我想取消 PC 作为要求,并将所有内容都托管在 pi 上.

I have managed to write a client-server-client solution where the signalR hub is hosted on a PC running IIS 8. A console app on the pi connects to the server hub with the c# signalR client. The asp.net server also hosts a 'remote control' page for a browser client to send commands to the pi but now I want to eliminate the PC as a requirement and have everything hosted on the pi.

推荐答案

TLDR

可以的!视频.代码.

长话

我设法找到了一个与 Nancy、SignalR 和基于 OWIN 的网络服务器一起使用的解决方案 NoWin 从 Rasperry Pi 上的控制台应用程序运行(单声道 3,硬浮动).请参阅此解决方案中的 RPi.Nancy 项目:

I managed to get a solution working with Nancy, SignalR and the OWIN based webserver NoWin running from a console app on the Rasperry Pi (mono 3, hard float). See the RPi.Nancy project in this solution:

https://github.com/neutmute/RPi.Demo

与连接到 IIS SignalR 主机的纯客户端相比,pi 作为自托管 Web 服务器稍微滞后一些.来自knockout.js 边界范围滑块的响应非常缓慢,更新流在客户端停止移动后需要几秒钟才能完成传送到服务器.在 PC 上运行相同的自托管服务器也表现出一些延迟,但没有在 Pi 上慢.

Compared to being a pure client connected to an IIS SignalR host, the pi as a self hosted web server is somewhat more laggy. The response from a knockout.js bound range slider is very slow taking several seconds for the stream of updates to finish feeding through to the server after it has stopped moving on the client. Running the same self hosted server on a PC also demonstrates some lag, but not as slow as on the Pi.

在运行自托管的 signalR 时,单声道进程消耗 97%,同时拖动滑块并传输信号流事件.在以 IIS 作为中心服务器的纯客户端模式下不会发生这种情况,但是当猛烈拖动滑块时,IIS 服务器确实会遇到高 CPU 使用率,因此也许应该原谅 pi 有点延迟.

While running the self hosted signalR, the mono process conumes 97% while the slider is being dragged and transmitting a stream of signalR events. This does not happen when in pure client mode with IIS as the hub server, however the IIS server does experience high CPU usage when there is furious dragging of the slider, so perhaps the pi should be forgiven for a little lag.

我也尝试将 Katana 作为网络服务器,但它的运行速度比 NoWin 还要慢.

I also tried Katana as the webserver but it ran even slower than NoWin.

请注意,完全自托管的 SignalR 解决方案可以正常工作,如果您只在这里和那里发送几个按钮按下 - 仅当来回拖动滑块并生成连续的事件流时,延迟才会明显.一种解决方案可能是通过敲除绑定限制来自滑块的更新,并降低滑块事件的分辨率.

Note that the entirely self hosted SignalR solution would work fine if one only was sending a few button presses here and there - the lag is apparent only when dragging a slider back and forth and having a continual stream of events generated. One solution may be to throttle the updates from the slider via the knockout bindings and reduce the resolution of the slide events.

另外值得注意的是,托管在 pi 上的 SignalR 不能使用 Web 套接字,因为它们仅在 SignalR 托管在 IIS 8 上时才可用.改为使用服务器端事件传输.在纯客户端模式下,这是相同的传输.

Also of note is that SignalR when hosted on the pi can not use web sockets as they are only available when SignalR is hosted on IIS 8. Server Side Event transport is used instead. This is the same transport when in pure client mode.

这篇关于Raspberry Pi 上的自托管 SignalR 可以工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆