Can self hosted SignalR on the Raspberry Pi work?

风流意气都作罢 提交于 2019-12-21 05:02:34

问题


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

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.


回答1:


TLDR

It can be done! Video. Code.

Long story

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

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.

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.

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

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.

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.



来源:https://stackoverflow.com/questions/21216122/can-self-hosted-signalr-on-the-raspberry-pi-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!