I heard node.js is an ideal framework for building real time web application (chatting, live feeds etc...), then i guess it involve lot of socket io connection between nodejs and client browser.
in client side do i have to use websocket(html5) in order to communicate with node.js, if that is the case, then most of the older browser won't support HTML5-Websocket.
Question :
are real time web applications built using node.js will work only with HTML5 compatible browsers.?
Many nodejs chat applications use socket.io.
socket.io has a fallback (involving pulling or Flash) for browsers not having websockets :
Socket.IO aims to make realtime apps possible in every browser and
mobile device, blurring the differences between the different
transport mechanisms. It's care-free realtime 100% in JavaScript.
The point of using socket.io is that you don't really care, you just use it and most browsers will use websockets while some won't (but they still will work as well as possible).
I heard node.js is an ideal framework for building real time web application (chatting, live >feeds etc...), then i guess it involve lot of socket io connection between nodejs and client >browser.
Yes, what you have heard is correct. It does involve a socket.io connection between client browser and the server
Read more about socket.io here
in client side do i have to use websocket(html5) in order to communicate with node.js, if >that is the case, then most of the older browser won't support HTML5-Websocket.
socket.io package of Node JS creates a WebSocket connection internally, if the client is using HTML5 enabled browser. In other browsers, it will fall back gracefully to different transport mechanisms.
Question : are real time web applications built using node.js will work only with HTML5 >compatible browsers.?
Above comments must have made clear, it will work in all supported browsers, if you use socket.io :)
See Browser support for socket.io
Related
The title pretty muchs sums it up... I am wondering if there is a way to use socket.io without node.js
socket.io is a library that connects a browser web pages to some server somewhere. There MUST be a socket.io server somewhere that does what you want that you can connect to.
That socket.io server does not have to be written using node.js. There is socket.io support for other languages or environments. The protocol and data format is fully documented so implementations can be written for any environment.
For example, here's a socket.io server implementation in C++.
You can look on github for various server implementations: https://github.com/search?q=socket.io+server.
I want to connect a bunch of weather sensors to a Raspberry PI. Writing the daemon that reads the sensors and writes the data to a database will be the easy part since I'm a systems programmer. I also want a simple cross platform UI for this device so I'd like to set my Raspberry Pi up as a WIFI hotspot that people can connect to and then just entering a URL like 'weather.local' into a browser which would take them to a web page where the weather sensor data is continually updated. I.e. I want the sensor daemon to 'push' updates to the web page.
The problem is that I'm no web developer. The solutions I can think of off the top of my head are:
Flash, which is out because I want this to work on mobile browsers.
Using Java script and hanging HTTP requests to a web service.
HTML5 socket.io which is presumably the same as WebSocket.
If I go with option (2) even if it's a kind of polling, I'll have to incorporate some form of HTTP server into my sensor daemon and I have a fair idea of how to code that. My question, however, regards the HTML5 socket IO. Can I use this to connect directly to a TCP/IP binary socket or do I need a server side WebSocket library? Also how widely is HTML5 socket.io/WebSocket implemented on mobile browsers?
WebSocket always begins with an upgrade handshake over HTTP, so you do need to have basic HTTP capability. It's simple enough that you can hand-code it.
WebSockets is basically supported by all modern browsers. It is not used that widely because it's a pain to set up on traditional HTTP servers and messes up with many proxies, but that's not a problem for you. As long as the client is a recent version of anything, it'll work.
A note about option 2: browsers have a native implementation of it — that means you don't need so much JavaScript on the client. You just create the EventSource object and listen to its events.
I'm currently working with nodeJS and Socket.IO. But the problem is : i having a website who only support recent browsers and so, websockets. I really don't need a 400kb client.js.
My question is easy : is there a nodeJS module who work only with websocket ? no fallback for old browsers, no ajax fallback etc... ?
Yes. Socket.io ultimately depends on the ws module to make WebSocket connections.
You can use this module on the server side in combination with the raw WebSocket client-side API. Note that in addition to losing fallback support, you also lose socket.io's automatic reconnection feature.
Also consider that it's not just the actual browser you have support. Many people are behind firewalls/proxies that don't support or actively block WebSocket connections. So even though the browser supports the API, your user will still be unable to use your app. For this reason, you may want to consider keeping Socket.io anyway.
BTW, the client code is only 20 kB gzipped, not 400.
There is a server I need to talk to that publishes a protocol over TCP/IP for querying data from a database and listening on a socket to receive notifications when data is updated. The sever guys provide a Java API which uses this TCP protocol. This means I could easily write a Swing App to talk to this server.
I would like a browser based solution. As the protocol is known to me, could I do this in JavaScript? My app will have to display the data in a table. I have heard of Web Sockets but I'm not sure if it will allow this two way communication. Is it feasible? Is there a better way that is cross platform and will work in most browsers? Should I be considering a Java Swing based solution that runs inside a browser?
EDIT: What about changing the code in my C++ server to add an additional interface that my Javascript code can communicate directly with it?
The WebSocket protocol differs from TCP/IP sockets. You will have to write something to link them together.
You can do this perfectly well in JavaScript: use Node.js. There's enough tutorials to be found on the subject. The best way to link it to your in-browser JS is through Socket.IO.
Create a Node.js server that connects to the api
Make the server talk to your web app
Use it :)
This will work cross-platform and cross-browser (Socket.IO can use/emulate websockets even on IE6(!!)). You'll have to run a server-app (the Node.js app) though.
My personal opinion is that if you want a web/browser based solution, you should use native technology, and not Java.
Hope this helps :)
I'm looking to connect my WinJS app to mobile browser clients via a cloud service that everyone connects to using web sockets.
I built a solution using socket.io that works well as long as my node.js server is hosted on localhost :) When I deploy my server to Azure, the Windows 8 app returns an error saying it can't load external content in a local context (after calling socket.io's connect()).
Looking at the web sockets sample on MSDN, I think that I should use the built-in functionality in Windows.Networking.Sockets for at least what's between my app and the public cloud service as it won't try to load external resources.
My question is: what are the options for the other end of the tunnel? Does it require a .NET 4.5 host with IIS 8 (since IIS 7 doesn't support WS)? I don't think those exist today yet, so I'm wondering what the development story is here.
Depending on what I end up using for the server, I think I'll have to use socket.io again or SignalR to serve the clients (most won't support web sockets and I need a good cross-browser library :))
If your backend is a NodeJS app, you don't need an IIS Server or anything related to the .NET Framework.
A list of hosting providers is maintained by NodeJS' author at https://github.com/joyent/node/wiki/Node-Hosting (The list might be outdated as I don't see Azure there).
I don't see why your server shouldn't work when deployed to Azure. Are you using npm install azure?
I have a feeling that you are confusing yourself regarding Web Sockets and Socket.io.
Socket.io is a realtime transport framework that might or might not use Web Sockets for its transport on the client-side based on the client's browser.
Refer: FAQ — Socket.IO
(Answering my own question)
I was behind a proxy that didn't allow the web socket connection from socket.io in my Win8 app through, and so it fell back on a method that required loading external resources.
Bypassing that problematic proxy, the connection works fine and I can use socket.io from my app as intended. I'm hosting the other end on Azure (per the node.js + socket.io tutorial they provide) and it works. I still don't know what a developer wanting to use the built-in web sockets library should use for a host, but I imagine we have to wait for IIS 8 to be out.
Now I'm left to verify that the app can pass certification with this library.