Can web sockets be used today without a .NET 4.5 host? - javascript

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.

Related

Pushing updates to web application without SSL

We have a web application that will have a text messaging feature. The messages need to synchronize in real time. My first thought was to use service workers but the problem is that the application is served from each client's own server and service workers require SSL. It is not feasible to install an SSL certificate to every client server. There is a central server that handles the messaging but the application will always be served from individual distributed servers without SSL. So basically, the problem is being able to push updates to the application without using HTTPS. Polling would be a simple but not very good work around. I was looking into integrating XMPP for the messages but after some research, I still don't know if that would work. The application servers are Apache with PHP.
Would integrating XMPP allow for live updates without using SSL?
Are there other protocols, technologies, or methods to solve this problem?

run node.js server for chat app in e-commerce website

I want to add a chat app to my e-commerce website which offers one-to-one chat between the buyers and the sellers. After searching ,web sockets seems to be right for this but it requires node.js server and the rest of my website is in php with apache server. I have read that it is not good to run both apache and node server at the same time. For video chat I'm using appear.in's javascript api which has no such limitations.
How can I run the node.js app under this scenario?
There are plenty of web socket libraries for PHP, e.g. Ratchet.
If this is the only reason for you to move parts of you application to Node.js, you shouldn't necessarily do it.

Node.js web application browser compatibility

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

How to access app hosted on meteor.com by DDP (WebSocket) protocol?

I have a Meteor app A and another application B, not using Meteor, but making some data exchange with the app A. It works fine when I launch A on a machine in my local network, but when I deploy it on meteor.com hosting it doesn't. Server doesn't reply.
B uses code new WebSocket("ws://" + host + ":3000/websocket") for connection (DDP protocol).
But when I change ws to wss it doesn't work any more even with the machine in LAN - it doesn't reply.
I saw that main page of app A when I open it in browser uses URLs like
wss://ddp--6774-{my host name}.meteor.com/sockjs/465/asf0b7da/websocket.
Questions:
How can I make B to use secure WebSocket (wss) for connection?
How can I make connect it to A hosted on {my host name}.meteor.com?
How can force A to reply to requests using fixed URL, for example, ws://{my host name}.meteor.com:3000/websocket ? How can I force it to use ws instead of wss?
Should I specify something in config.js or settings.js?
Is there any way to specify environment variables for meteor.com hosting, for example, DDP_DEFAULT_CONNECTION_URL, NODE_OPTIONS?
The websocket server is handled by sockjs, so as long as you use a standard wss it should 'just work' (see https://github.com/sockjs/sockjs-node). If you're websocket implementation on your client is built to use websockets it should be ok. The atmosphere/meteorite projects use the node-ddp client with secure sockets (there were a couple of issues but I think theyre sorted). (In turn which depends on the faye-websockets library)
I'm not too sure which language you're coding your app B in, but you need to use a DDP client to connect to your server, or you could write one, the DDP spec is fairly open and reversible.
There are a couple of DDP implementations out there, some might need to be brought up to date to the pre-1 release spec:
Java (https://github.com/kutrumbo/java-ddp-client)
Ruby (https://github.com/tmeasday/ruby-ddp-client)
NodeJS (https://github.com/oortcloud/node-ddp-client) - Up to date
Objective-C (https://github.com/boundsj/ObjectiveDDP)
.NET (C#/VB.NET) (https://github.com/sonyarouje/DDPClient.NET)
Additionally you might run into trouble, as you discovered a connection to new WebSocket("ws://" + host + ".meteor.com/websocket") is fruitless, this is because meteor deploy hosting uses a ddp proxy (which is accessed via ddp--xxxx-{my host name}.meteor.com, but the xxxx also always changes when you make a new deployment, you have to access the html file and parse out what the ddp server is or make a note of it every time you deploy your app.
If you connect on port 443 it should be wss. I'm not too sure websockets do redirects. This is a server side thing, so if you're using meteor deploy you wont have control over this yet (perhaps when they release galaxy this might change). Perhaps the force-ssl package might help? Not too sure if it also enforces the websockets part of the connection too, though.
For DDP there aren't any known settings you can specify in the settings
For meteor deploy hosting you can't alter the DDP server to use another one or alter the environmental variables (see https://github.com/oortcloud/unofficial-meteor-faq).
Keep in mind meteor deploy hosting is very young & the guys who make meteor still haven't released their galaxy solution so this might all change in the future.
Btw sorry about the layout/spacing, I can't get the hang of this markdown thing.

Using Gigya API with node.js

For one of my projects I'd like to try out Gigya as my social network connection provider and am writing my app using Node.js. Has anyone done this?
Gigya provides a JavaScript API that is intended to be used on the client.
http://developers.gigya.com/020_Client_API
It should be possible to adapt that for server side use.
Gigya's client side javascript is intended to be run in the browser as much as possible, since they perform 2 part authentication using cookies set by their domains. You can try to port it to run server side, but none of the public methods will work as advertised.
I've written a wrapper for their REST API using their proprietary authentication that I've been using in a work project for a few weeks: https://github.com/jproulx/Gigya-Node-SDK -- note that not everything has been tested thoroughly as I've only needed to use a subset of the socialize services on the server side. It should serve as a good jumping off point to bootstrap something for your needs.
Gigya does not yet have an official Node SDK. However, I've written an SDK that implements the entire service.
In addition to the standard APIs, it contains special support for streaming data from Accounts & DS.
Git: https://github.com/scotthovestadt/node-gigya
Install with "npm install gigya".

Categories