Can StreamSocketListener host SignalR? - signalr

I have a Universal Windows Platform app running on Windows IoT (ARM) that starts up a web server via StreamSocketListener. I'd like to be able to push content to web browsers via SignalR. There's an enormous number of SignalR nuget packages, but it appears that none of them will work in UWP. Is this correct? If so what is my best option for pushing content down to browsers?

For modern web browsers, SignalR would use Web Sockets for bidirectional communication with the client. You can see if your client browser will support Web Sockets at Can I use.
There is an open source project whose specific goal is providing a Web Socket server in a UWP app. I don't have first-hand experience with the project and it's <1.0 but it mentions compatibility with Windows 10 IoT Core so it may be worth exploring. You can find the project on NuGet here: https://www.nuget.org/packages/IotWeb/
On the client, you can then use the WebSocket object in JavaScript to open a connection with your server.

Related

Hosting Meteor Application

I am building Meteor application which I want to later publish it on IOS and Android.
My questions are:
1) Is it possible to host my Meteor application on my own Ubuntu server?
2) Because Meteor server and client sides are bundled into one. How will the Mobile versions connect to the server?
Yes. Ubuntu, Debian, and other Linux distributions will work well too.
Over DDP (WebSockets) or XHR, if WebSockets fail to connect. It's the same as in browser, in fact Cordova (which is used in Meteor to build "native" app) is a wrapper around Safari in iOS and Chrome in Android, kind of full-screen/interface-less browser, with bindings to native Swift/Objective-C/Java.
Yes. You can host a Meteor app in all sorts of places including your own server. Galaxy and Digital Ocean are both popular cloud options.
When you build for iOS and/or Android you end up with apps that you can post to the App Store and Google Play. The server code is not bundled into these. Meteor's mobile guide describes how all this works in detail. The server address is configured via the ROOT_URL (docs). Essentially the client has the server's address configured into it so it knows where "home" is. This should obviously not be an IP address since that can change.

Deploy a desktop application from a web site

I have a requirement to install a desktop application written in visual c++ when our customers log in our asp.net web site. The desktop app will be installed once, but will be updated as a newer version is available. What is the best way to do this?
My second question is that is there a way for my asp.net web app to interact with a window service installed on customer computer and direct the window service to control USB devices.
My work uses software by a company called Citrix. There is some client side software that goes on the client's PC. When setup correctly, we can click a link on our sharepoint site that will trigger the citrix client software to launch a WPF desktop application from a network drive that will run locally on the clients computer (might be in a virtualized space that Citrix creates). This seems to work well, it runs our WPF applications that use windows authentication. This is all I know about it. You can research more if you're interested.
To answer that second question... Your window service would need to expose some kind of service for the client (asp.net web app) to communicate to it with. So ideally I think setting up the windows service to host a WCF service inside it and use something like named pipes or HTTP protocol to communicate with your application. I don't know what kind of USB devices you are trying to control though, that will take research on your part. But if you can control them with a local console application, you should be able to do the same with a windows service.
Good luck. Hope this was helpful.
You can't install an app from a web site, best you can do is prompt the user to download the installer. And asp.net (or any website in general) can't interact with the window service on the client. Imagine going to a website which changes your service settings, installs viruses, etc. A website is pretty much limited to changing cookies and local storage on the client, anything else on the client is inaccessable.

does self hosted signalr require windows server 2012 in order to use websockets?

A self hosted application doesn't seem to run off of IIS, so does it require a specific operating system in order to enable web sockets on the server side?
Browsers will support it because they have implemented the protocol internally, most browsers won't use the operating system transport libraries so they will be able to make use of WebSockets even if the OS does not directly support it.
HTTP.SYS prior to Windows 8/2012 has no built in support for WebSockets, so although .NET 4.5 contains WebSocket classes, they won't work unless you are running .NET 4.5+ on Windows 8/2012 and that will affect self-hosting solutions running in Windows < 8.
The implementation resides in the operating system code that .NET and IIS8 just leverages. The .NET classes simply wrap calls through to HTTP.SYS so it will throw an exception on an operating system that does not have underlying support for it.
When self-hosting you can however use your own internal Web Socket server such as Fleck and tell SignalR that you in fact do support Web Sockets regardless of your OS.
Start a Fleck server in your self-hosted application (examples on their site) and as an example you can do this for a PersistentConnection self-host:
public override Task ProcessRequest(HostContext context)
{
// Override what SignalR will be telling you internally and point to your own Web Socket Server.
context.Items[HostConstants.SupportsWebSockets] = true;
context.Items[HostConstants.WebSocketServerUrl] = "ws://localhost:3000";
return base.ProcessRequest(context);
}
Disclaimer: This is an undocumented feature, the developers of SignalR have told me that this may not be possible in future versions of the library. Keep in mind that you will also need to cater for keep-alives and serializing your data to JSON so it plays nice with the SignalR clients. It still works in version 1.1.3.
I've know for sure that websockets are not supported now by doing a quick test. I created a self hosted hub and then a quick jquery client. On my windows 8 machine the querystring showed websockets, on the server 2008 r2 it showed long polling...
Yes it requires windows server 2012 check the quote below from SignalR Supported Platforms
The SignalR server component can be hosted in the following server or
client operating systems. Note that for SignalR to use WebSockets,
Windows Server 2012 or Windows 8 is required (WebSocket can be used on Windows Azure Web Sites, as long as the site's .NET framework version is set to 4.5, and Web Sockets is enabled in the site's Configuration page).
Also a good read on why can be found here

SignalR won't use Websocket protocol even though I have the protocol installed in windows 8

I'm using signalr to do some real-time events in my web application. I'm trying to force signalr to use the new websocket protocol but it won't, even if I specify it.
$.connection.hub.start({ transport: 'webSockets' })
I definitely have the web socket protocol installed and I am running Windows 8 with IIS 8.
What else do I need to do to enable web sockets support in signalr?
Ensure that your app is using the .NET 4.5 assembly from the SignalR package. If the project is targeting 4.0, or it started that way, then nuget would have added a reference to the 4.0 SignalR assembly which doesn't support websockets. If that's the case, then just uninstall and re-install the signalr packages into your project.
Web Sockets requires .NET 4.5.
If you try running it on Windows Server 8 in the future be sure to activate the Web Sockets feature.
If you are already using framework 4.5 but still no luck, add an HTTPS binding to your IIS website and access the website over HTTPS.

how to connect to a web service from windows mobile(when running emulator)

I have as asp.net webserver that I hosted and I went to my mobile application I am building and made a web reference to it.
So it finds it and stuff and now I can access the web methods because of the wsdl generated. However when it tries to connect I get this:
Could not establish connection to network.
So do I have to enable something to make this work?
Take a look at this article. It explains how to setup your mobile device for internet connectivity.
Windows Mobile Emulator and Internet Connectivity
It's been awhile since i have had to do this. Perhaps it is as easy as Matt has suggested, I can remember having a hard time making this work with Windows Vista, Visual Studio 2005 and the Windows Mobile 5.0 Pocket PC Emulator. I've found a couple more articles, hope this helps.
HOWTO: Configure Network in Windows Mobile / PocketPC Device Emulator
Making Emulator to connect to the Network
I have used web services and rest based services via webrequests on the emulator without needing to configure the NE2000 adapters.
Change activesync or WMDC to connect using DMA (in wmdc: mobile device settings | connection settings, then set 'allow connections to one of the following' to DMA)
Then in VS2008, under tools select device emulator manager, and pick the emulator that is running, right click on it and select cradle, this should connect activesync/wmdc to the emulator and provide a network connection that is sufficient to communicate over http with web services.

Resources