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?
Related
For my job, I am doing research on finding a means on how a web application running locally from file:\ in IE11, created with either HTML5 or Javascript, can access the raw data or listen to a computer's serial port being sent out from a windows service or proxy. The situation is that We have a proxy designed to collect data from a computer's serial port and it will send that data outward on our network to the local host.
What we want our web application to do is to catch that data the proxy is sending out directly from the service on the computer, removing the need to have the proxy send the data to a server and having the web application collect the data from a server. So far googling the solution has been difficult. Does anyone know the solution to our problem or knows where to find the solution?
Lazy people, why don't you use Google search bar (!?!)...
Here: https://github.com/garrows/browser-serialport
Note: You cannot use this in a Web page, i.e. cannot put it on a Web server. And it is supported only by Chrome.
I'm creating an app where the server and the clients will run on the same local network. Is it possible to use web sockets, or rather more specifically, socket.io to have one central server and many clients that are running native apps
? The way I understand socket.io to work is that the clients read the web-pages that are served from the server but what happens when your clients become tablet devices running native apps instead of web pages in a browser?
The scenario I'm working with at the minute will have one central server containing a MEAN app and the clients (iPads) will make GET requests to the data available on the server. However, I'd also like there to be real-time functionality so if someone triggers a POST request on their iPad, the server acknowledges it and displays it in the server's client-side. The iPad apps will (ideally) be running native phonegap applications rather than accessing 192.168.1.1:9000 from their browser.
Is this technically possible to connect to the socket server from the native apps or would the devices have to send POST requests to a central server that's constantly listening for new 'messages'? I'm totally new to the whole real-time stuff so I'm just trying to wrap my head around it all.
Apologies if this isn't totally clear, it's a bit hard to describe with just text but I think you get the idea?
Correct me if I am wrong.
You have multiple iPads running native app. They send a POST request to your node JS server which is running in a computer in the same local network. Whenever the server receives a request from app, you want to display that a request has been received in your computer screen.
If my assumptions about the scenario is correct, then it is fairly easy to do. Here are the steps to do it.
Create a small webpage (front end). Load socket IO in the front end page like this -
<script type="text/javascript" src="YOUR_SERVER_IP/socket.io/socket.io.js"></script>
Then connect to server using var socket = io(). This should trigger connection event in your backend.
Handle all POST request from apps normally. Nothing special. Just add a small snippet in between. socket.emit('new_request', request_data). This sends new_request event to front end.
Handle the new_request in your front end using socket.on('new_request', function(request_data) { ... });. That's it. No need to add anything to your native app for realtime update.
The second step would be a little complicated as it is necessary to make socket variable available inside all POST requests. Since you chose node.js, I don't think you need any help with that.
Not totally clear on your project, but I'll try to give you some pointers.
An effective way to send data between native apps and a server is using a REST server. REST is based on HTTP requests and allows you to modify data on the server, which can connect to your database. The data returned is typically either JSON or XML formatted. See here for a brief intro: http://www.infoq.com/articles/rest-introduction
Android/iOS/etc have built in APIs for making HTTP requests. Your native app would send a request to the server, parse the response, and update your native UI accordingly. The same server can be used from a website using jQuery ajax HTTP requests.
Express.js is more suited to serving web pages and includes things like templating. Look into "restify" (see here: mcavage.me/node-restify/) if you just want to have a REST server that handles requests. Both run on top of node.js (nodejs.org).
As far as real-time communication, if you're developing for iOS look into APNS (Apple Push Notification Service). Apple maintains a persistent connection, and by going through their servers you can easily send messages to your app. The equivalent of this on Android is GCM (Google Cloud Messaging).
You can also do sockets directly if that's easier for you. Be careful with maintaining an open socket on a mobile device though, it can be a huge battery drain. Here's a library for connecting ObjC to Socket.IO using websockets, it may be useful for you: https://github.com/pkyeck/socket.IO-objc
Hope that helps!
To answer your question, it is definitely possible. Socket.io would serve as the central server that can essentially emit messages to all of the client. You can also make Socket.io listen for the messages from any of the clients and serve the emitted message to the rest of the clients.
Here's an example of how socket.io can be used. Simply clone, npm install, and run using 'node app.js'
All you have to do is to provide a valid server address when you connect your socket from the iPad clients:
var socket = io.connect( 'http://my.external.nodejs.server' );
Let us know if you need help with actual sending/receiving of socket events.
It is possible to connect to Websockets from your apps.
If you are using PhoneGap then you need a pluging that gives support to websockets in your app (the client) and then use websocket like normal way using Javascript see this.
If your app is native iOS look into this it could help you.
The primary use of the Sockets in your case is to be a bidirectional "pipe" between an app and server. There is no need of server sending the whole web-page to the native app. All what you need is to send some data from server to the client(app) in response to POST (or GET) request and then using this data on client side to update client's UI in real-time. If you are going to use moderate amount of devices (say tens of them), you may have connected all of them to the server permanently keeping individual socket connection open for every individual link server-to-app. Thus you may deliver data and update client's state in real time.
In fact web browsers also employ sockets to communicate to web servers. However as in general case there is no control on amount of concurrent clients in Internet, for the sake of limited networking resources conservation, servers do not keep sockets open for a long time, closing it just after the web-page was sent to client (or timeout has expired). That's how HTTP protocol works on the low level. The server waiting for the HTTP clients (browsers) by listening the 80 port, responding them by sending the whole web page content, then closing the connection and keep waiting for another requests on the same port.
In your case it's basically a good idea to use socket.io as it's a uniform implementation of sockets (ok WebSockets) on both client and server side. The good starting point is here
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.
Is it possible to send directly message from JavaScript in client browser to 0mq?
If not in JavaScript, then I should use Flash or setup some http proxy server?
0mq is not meant for Internet facing ports. There is a project called nullmq which does what you want though by translating from web protocols to zmq behind the firewall, while retaining zeromq like api on the browser.
I suspect it would be easiest to have your client browser make an XMLHttpRequest() to your web application and then have your web application talk to your 0MQ infrastructure.
There is a javascript/flash binding for 0MQ, but I've never worked with it myself so I can't comment on stability or anything.
If you tell us more about what you're trying to accomplish we might be able to suggest viable alternatives.
You can use websockets on the client-side if you want a persistent connection and use a websocket server like tornado or socket.io to relay the messages to zmq and back.
I don't quite know how to search this in google:
"client to client websocket connections"
"browser to browser websockets"
"websockets without a server"
Haha, is there a way for someone on a webpage in the browser to communicate directly to another person on a web page in the browser, without touching the server?
I am very familiar with socket.io, but that requires all clients emit messages to the server, which can broadcast them to the other connected clients. I am not familiar with the details of web sockets though, so maybe there's a way to communicate without sending messages through the server.
Is this possible? I just want to know the scope of web socket functionality, the limits you can take them too, etc.
Not Web Sockets, but four years later and now we've got browser-to-browser communication!
http://www.webrtc.org/
There are JS libraries built around it to make it easier (e.g. https://simplewebrtc.com/). However, it does still require a server to orchestrate connections.
I know this question is ancient, but it showed up in Google when I searched so it likely will for others!
This is not possible, you have to have the server in the middle.
For an application to accept connections, it has to have a server port open and listening for incoming requests. You cannot have a server socket exposed from a browser. I dont know if you can expose a server socket from within an applet. But even if you could, you would need to know the IP address of the other client for establishing a peer to peer connection.
Well, technically when you broadcast, the client emits to the server, the server broadcasts to everyone. I don't think with the current architecture of the web peer to peer connections like this is possible.
But it is possible that a client send a message to server specifying another client ID, and the server sending it to the other clients using sessions.
The moment you have a client listening for websockets (which you have to do in other to communicate), it becomes a server.