How to setup a Websocket connection on Windows Azure? - c#

Does Azure support the use of WebSockets for .NET, if so how can a Websocket connection be initiated and handled?

Web Sockets are now supported in Azure Web Sites. To use them, go to the site Configuration page in the management portal and turn on Web Sockets.

At the moment this isn't possible. You'll only get websockets when Azure (Cloud Services or Web Sites) supports .NET 4.5 on Windows Server 2012 (IIS8), which isn't the case at the moment.
Today .NET 4.5 is only available in Web Sites with Windows Server 2008 R2 (IIS7).
Note: Technically you can use other solutions (as opposed to IIS) to get websockets in your Azure application (like Pokein, SuperSocket, ...)

As Sandrino says this is not possible unless you have win8/2012 with .net 4.5.
However, that´s if you are running SignalR (or WebSockets in 4.5 of course).
We have been using websockets on Azure for quite some time now, and it is working really well.
You can try it at http://live.xsockets.net or our really simple playground http://xfiddle.net
Regards
Uffe

Related

Is it correct to use SignalR for desktop applications?

Is SignalR suitable for windows desktop applications (winforms/wpf)?
What are the advantages and disadvantages using SignalR with windows desktop applications?
Are there any performance considerations?
I want to make real-time connections between server and a lot of clients. The connections will be constant.
Is SignalR suitable for windows desktop applications (winforms/wpf)?
The answer from signalr.net is:
SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application.
(As stated correctly by others it can be self-hosted, so no need for IIS)
So the answer seems to be no. It is a server side API. But today is your lucky day, since the download of SignalR doesn't only reveal the server side API, but also a client side API called Microsoft.AspNet.SignalR.Client45 to use in your application. It works for WPF, WF or even console applications.
And even if it didn't, SignalR is just a wrapper around the WebSockets protocol, which is part of the HTTP protocol, which can be used on virtually any platform. The download also contains a sample for iOS and Xamarin for example.
What are the advantages and disadvantages using SignalR with windows desktop applications?
To have real-time notifications from and to the server.
Is there any performance problems?
That is a hard question to answer, since there is no reference point. Compared to what the performance is good or bad? Generally spoken, I don't think you have to worry to much about that. The API itself is fast, and it may prevent slow pull-requests you need to do else.
It is absolutelly correct to consume SinglarR hub in any client application, WPF, windows phone, UWP, iOS, Android, including HTML. Microsoft has created client libraries on many platforms.
When it comes to hosting SignalR, then you can definitelly host you SingalR server (hub) in WPF application, but you need a reason:
The reason may be:
IIS is not available
You don't know in advance where the APP will
be used. You just need to run an app, that will notify other apps
Performance - IIS adds some performance overhead.
By the way, SignalR and OWIN has been an inspiration for the new ASP.NET 5. You can now host your ASP.NET apps in WPF, console application or windows service app without IIS, or even on Linux.
http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host
In a setup with a server and many clients: If you need "push" notifications from the server to some clients then SignalR is good to use.
I do so with WPF clients.
When you build a website with signalr functionality you have a signalR server, where the site is hosted and a signalr client, the javascript client that runs in the web browser that browses the site.
From years immemorable, web browsers were (and still are)... well,... desktop applications...
So you have desktop applications (the web broswer) that use SignalR to connect to a web site (the web server).
So, not only is it correct to use signalR for desktop applications, but this is what it is meant for. I really don't know what would be the use of signalR if it wasn't to be used in a desktop application at some point, because, frankly, a user sits in front of a desktop (or a smart device), and doesn't exist "in the cloud" (unless you are Neo from Matrix). With signalR you have "real-time" reactions from the server presented in your desktop environment (a web browser or another desktop application, for instance an application that controls the lights in your home, or prints something in your printer).

Can we create Server in desktop application using SignalR?

I need to develop desktop application as a Server using SignalR. I want to know SignalR is only for ASP.net webapplication or it can be used as Desktop application?
On SignalR client side, SignalR provides client libraries for .NET, JavaScript, Silverlight, Windows Phone, Windows RT and even iOS and Android through Xamarin.
On server side, can we make Server in desktop application using SignalR? SignalR possible in visual studio 2010 or higher version?
Yes you can.
What you are searching for is named "SignalR Self-Host"
Tutorial from Microsoft:
http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host
Tip:
Use Win8 or Win2012 for the host for WebSocket support.

How to host WCF web service over the internet?

I work as a C# developer and we have many .NET web services that we use. I am doing some at home development and want to do something similar. I have a database (SQL Server 2012) on a home PC running Windows Server 2012 with IIS 8 installed. I have created a WCF web service in Visual Studio (C#) and it compiles to a .svc file. This just facilitates data exchange between my SQL Server Database and the application I am writing.
I am unfamiliar with how to host the WCF service so that the Windows Form application that I am writing that will be installed on many non-local machines can access it. I figured a WCF service would be the best choice for accessing my database for the WinForm application over the internet.
I also have a domain with a basic Windows package on 1&1.com leftover from a previous project if that helps.
Can anyone give me some steps to get my WCF service hosted so it can be accessed over the internet? Please ask if I forgot to list any needed information.
Two common ways are to host your WCF service from IIS, or to self host it yourself from within a simple wrapper program that acts as a TCP server.
See http://msdn.microsoft.com/en-us/library/ee939285.aspx
The simplest way is to setup IIS and just publish your services like you would a web application; your service will exposed over http/https. Use an appropriate binding like wsHttpBinding or BasicHttpBinding depending on your security needs. Read up to understand the different bindings and what each does and does not support.
In order to host WCF via IIS, at least on Windows Server 2003 and 2008, make sure you follow the install steps, such as adding .NET 3.5.1 / WCF options on older platforms. I believe Server 2012 includes it within .NET 4 framework, but I haven't yet done it on 2012.
Google "WCF hosting IIS" for steps / setup guides.
There are also hosting providers that specifically provide WCF hosting solutions, though I'm pretty sure your current provider, since it supports IIS, should do fine.

What are the limitations of WCF HTTPBinding?

I am developing a .NET application (say A) which will talk to other .NET applications (say B). The application A is going to be consumed by a Java application (say X). I am currently using Apache Thrift. Thrift is great except for the basic support for OOPS features (such as overloading and inheritance). Of course, we can customize the Thrift compiler in the way we want as it is a open source technology.
One of my friend suggested to use WCF for application A and to use WSHttpBinding. Does WCF service when using Basic/WSHtppBinding has any limitations other limitations to go ahead with that? I guess the limitations of web service are applicable for the above stated way of hosting. Please guide me in this.
I have worked on a few projects where we have had to integrate WCF and Java. I have always ended up going for the BasicHttpBinding as that has allowed the two technologies to communicate with the least amount of friction. You lose a lot by using BasicHttpBinding over WsHttpBinding but that has not been an issue with the projects I have worked on. You are going to have to make the call between ease of use (BasicHttpBinding) and support for more/newer standards (WsHttpBinding).
Take a look at http://www.codeproject.com/Articles/36396/Difference-between-BasicHttpBinding-and-WsHttpBind
Limitations of WCF are :
ASP.NET 4.0
Visual studio 2010
IIS 7.5
MS SQL server 2008 R2

How to use SignalR with .net 3.5

I would like to build a winform business solution using SiganlR, but I am not able to install .net 4.0 on the client machine. It looks like SignalR has a mininum requirement of .net 4.0. What is the best way to use SignalR from a winform and .net 3.5. I would like to include the send/receive message functions in the client application.
I will be hosting SignalR on IIS on my intranet using .net 4.0 on the server side.
Would it be possible to create and API (in .net 3.5) similar to pubnub C#? Can anyone point me in the right direction.
If you're not too scared of compiling your own stuff I have created a .net 2.0 compatible client library for SignalR. It's available right off my fork (https://github.com/robink-teleopti/SignalR) of SignalR.
At the moment I have no intent of making a pull request as I don't want to add that extra burden to the original project.
I have one more modification on my fork that can be good to know about. When having clients belonging to more than 20 groups I automatically switch to using POST instead of GET and I have made minor modifications on the server side to handle that part.
I backported the v1.x and v2.x SignalR clients to NET35. Available as NuGet packages here: http://www.nuget.org/packages/Nivot.SignalR.Client.Net35/
One of the authors of the SignalR project had a goal of using TaskParallelLibrary (TPL) that shipped in .NET 4. So I doubt any of the C# code from that project will run on .NET 3.5. Why not host a TCP or named-pipes WCF endpoint on the server and use normal .NET client callbacks? This is relatively easy if server is Windows Server 2008 with WAS or AppFabric.
If an older server you could host WebBrowser control and use SignalR javascript client library to handle signaling.
In another 6 months I'd bet on a native .NET 3.5 client library, but as the maintainers are full time MS employees I doubt they will have time to get to supporting legacy versions any time soon.

Categories