I want to develop a web application in which client calls a service on server to do some action which involves some processing. Server will do all the necessary processing and when the updated data is ready it will push that data to client. Currently I am considering two approaches: -
1. Using ASP.NET WEB API with SignalR
2. Using WebSockets with WCF in .NET 4.5.
My server will be on Windows Server 2012 but majority of my client will be IE 9 which I think do not support WebSockets.
As written in the SignalR documentation that it automatically falls to Long Polling if WebSockets support is not present without changing the application code. Whether this is also supported by WebSockets in .NET 4.5 or I have to do it manually. Means whether I have to implement both the Pull method and push method on the server.
Please guide me, which approach I will have follow.
In later use case I want to build this web application using PhoneGAP to create mobile app for iOS, Android & Windows Phone.
WebSockets does not fall back to longpolling (that doesn't really make sense). SignalR is a higher level abstraction over http transports and that's why it does the fallback and other things (like provide a nice programming model over a connection).
If you choose to use websockets on ASP.NET (not sure about WCF) you'll be programming against raw sockets (this means reading/writing array segments etc) and doing a good job at that is hard. SignalR does this for you and will fallback to several other transports (forever frame, server sent events, longpolling) if websockets isn't available on client or server.
Regarding clients, if you choose to use SignalR you'll need to use a SignalR client. We only have support for javascript and .NET (silverlight, windows phone 8, winrt, .NET 4 and .NET 4.5). Some people have written clients for other platforms including iOS and Android but we don't maintain them so I can't speak to how up to date they are.
I'd recommend you use SignalR so you can focus on your application logic instead of messing with the low level programming model of websockets.
You could start with the ASP.NET Tutorial http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
After this tutorials you know all the basic thing you need to know about SignalR
I can confirm that the fallback works automatically. If websockets transport can't be used, ServersentEvents transport would be used.. and so on.. the last transport protocol is longpolling.
Our SignalR server is a .NET 4.5 framework app, hosted in an ASP.NET MVC App using 4.5 dlls on a windows 2012 server. The application pool is ASP.NET 4.0.
A .NET 4.5 client on a Windows 8 or a windows 2012 server seems to use websockets.
The same .NET client on a Windows 7 machine (even with framework 4.5 installed) falls back to serversent events transport automatically.
With Signalr javascript clients on a browser, a similar thing happens:
Chrome/Safari/other browsers that support websockets seem to use websockets.
IE/other browsers that don't support websockets, but are relatively late versions seem to use serversentevents.
From experience, serversentevents is not very bad, therefore don't be put off if websockets isn't being used and certainly don't use that as the sole factor against using signalR as the benefits are many.
Hope this helps.
Related
I am still thinking what is the most proper WebSockets framework to learn, which gives me all what I want.
I am C#.Net Core programmer (it is the language I want to use to write my server with). I wanted to start learning SignalR, but I didn't start yet because I am still confused about the ability of using my SignalR server from a Microcontroller client.
Is it some how possible to use transfer data between SignalR C#.Net Core server and an ARM Cortex M4 microcontroller programmed in C (without any operating system on it)?
In case that is not possible with SignalR, which WebSockets framework may be useful for my case (C# Server <-> C client)?
Any further ideas and suggesions about that? I am still very new to WebSockets and I don't understand exactly if it is possible to use SignalR (or any WebSockets framework) server from a client uses another framework (or maybe pure websockets).
If you are using SignalR for ASP.NET Core you can actually use bare websocket to connect to the server. I showed a demo where I have 3 different clients connecting to the SignalR server. The interesting part is that one of the clients was a NodeMCU based board running lua. You can find all the details in my post including code and instructions on setting things up.
Already i built chatting application in(Android, iOS & windows phone) & established in asp.net WebAPI, Now performance is very poor.
After googling i found, XMPP is the best & free(I am planning to use free open source tool, don't suggest paid lib)
Instead of XMPP, why we can't try with signalR?
Suggest me, which one should I go & start establishing the API.
I know compared to SignalR, XMPP have lot of features.
Of course you can do it also with SignalR, or even as a combination of XMPP and SignalR.
XMPP is a complete presence and messaging protocol with lots of features and many available extensions (also non IM features). Its in production for over a decade now. It gives you all you need to build a IM/Chat app for free. So why to reinvent the wheel and rebuild all the existing functionality on your own with SignalR when you can just install an existing XMPP server, get a client XMPP library and start coding your chat application.
First of, I read the information here http://signalr.net/
You may have heard of WebSockets, a new HTML5 API that enables bi-directional communication between the browser and server. SignalR will use WebSockets under the covers when it's available, and gracefully fallback to other techniques and technologies when it isn't, while your application code stays the same.
SignalR also provides a very simple, high-level API for doing server to client RPC (call JavaScript functions in your clients' browsers from server-side .NET code) in your ASP.NET application, as well as adding useful hooks for connection management, e.g. connect/disconnect events, grouping connections, authorization.
And from answer here: How SignalR works internally?
SignalR has a few built in transports:
WebSockets
Server Sent Events
Forever Frame
Long polling
I have a little problem with understanding the article (theoretically).
So how does SignalR work briefly for each build in transports? (easy English may help, since I'm complete new to SignalR and web socket)
WebSockets
Server Sent Events
Forever Frame
Long polling
We need to make client - web server application with minimum code rewriting on server side:
Clients
Web browsers;
Desktop application (win, mac);
Iphone (web and native);
Android (web and native);
(maybe some other mobile platform);
Web server
.Net with IIS 7.x
Application has to run on different devices, and communicate with server over secure connection. We would first develop web application, then desktop, and later mobile version.
We don't want to rewrite server side code. Client side code rewriting is unavoidable anyway...
We were thinking to make following data exchange architecture:
For browsers we would use: HTTPS, HTML, JSON, XML, AJAX...
For desktops and native mobile apps: HTTPS, JSON, XML (no need to for HTML tags)...
Well, you should use something like the Model View Controller architecture, which would allow you to achieve your goal of code reuse. Your rich client application would simply use the JSON/XML based API you create. This is a pretty common method of achieving the goal and I think it is pretty sound.
I was doing AJAX implementation and would like to use Websocket when the client web browser supports it. Is there any frameworks that supports Websocket but falls-back to other methods when it detects the client side doesn't support Websocket.
There is also Atmosphere
http://atmosphere.dev.java.net
which support both client and server.
Yes sort of see www.kaazing.org
Kaazing Gateway supports all major browsers (Firefox version 1.5 and higher, Internet Explorer version 5.5 and higher, Safari version 3.0 and higher, Opera version 9.5 and higher, and Google Chrome version 0.2 and higher).
Socket.io is designed for this.
http://socket.io/
It is purely javascript that tries several different transport methods including XHR long-polling, WebSocket and FlashSocket amongst others.
You could also use Nirvana from www.my-channels.com.
When WebSocket is not supported it will fall back to a Comet based approach transparently.
Of course, you could try using jWebSocket, it is a pure Java/JavaScript high speed bidirectional communication solution for the Web - secure, reliable and fast. jWebSocket is provided to you to create innovative HTML5 based streaming and communication applications on the web. HTML5 WebSockets will replace the existing XHR approaches as well as Comet services by a new flexible and ultra high speed bidirectional TCP socket communication technology. jWebSocket is an open source Java and JavaScript implementation of the HTML5 WebSocket protocol with a huge set of extensions. Some demos or examples can be seen for you in the website, you can visit it here: https://jwebsocket.org/