Introduction: I want to develop the chat client that user can chat on the browser and I use the protocol call xmpp. Because of HTML5 web socket not yet available I try flash xmlsocket instead.
Problem: I cannot connect to the server via browser. I'm not sure why, but I think that it is the problem of the server configuration.
Question: Which is the best jabber server suitable for this job?
Most probably this is a permission issue. Either that or you've just configured the wrong host/port to connect to. Flash is not allowed to connect to other hosts than the one it was gotten from itself. You have to explicitely allow flash connections on the receiving side of the request (so on the chat server that you are connecting to). Google for crossdomain.xml to get more info.
ejabberd sounds like a suitable option for you. ejabberd is xmpp server written in erlang and is used quite widely. Many of the well known web based im services like www.meebo.com etc are known to be running on ejabberd. It allows you to install other transports which would let you enable talking to users of other protocol like yahoo, msn, icq etc.
You can also have a look at the xiff action script library by ignite realtime. It is an xmpp client library in action script. If you use this library you would just need to implement the ui components.
Hum... flash is ok, but you'd be better of using something like BOSH, which is basically an HTTP layer over XMPP.
Ejabberd would be a good server, as it supports BOSH, I don't know about OpenFire or Tigase (but I'd say they do). Other servers should be looked at carefully because they don't seem to have a "dynamic" community.
You will need a lot of Javascript, and for that, I can recommend StropheJS, which is probably the very best library out there today.
We have created a MUC (Multi-user chat room) client called Aristochat that works in the browser recently at Superfeedr. You can find the code on Github and an example here.
Related
I have a question which I can't seem to answer after searching for an answer on google.
I have a website hosted on a web host, but I want to introduce some real-time functionality on it, like a real-time notification system, or maybe a chat system.
As I understand the short-polling and long-polling methods of simulating a live feature are kinda obsolete. Today with the modern HTML5, we can use Websockets as I understand, or APE(Ajax Push Engine).
The thing is that I don't understand, how do I use websocket or APE on the webhost if they require a server to which they connect in order to work ?
How can I run that server along with my website on the same host ? Or maybe I am missing something ?
Can you give me some information on this problem, that I can read?
Thank you.
WebSocket is just another protocol. It works on port 80, so luckly you don't need a new server.
You just need to implement an abstraction level on your backend (but maybe it can do itself) that gets the HTTP request and looks if there are the upgrade headers.
If the answer is yes, go to websocket code, if not use standard HTTP.
I have been working with node.js for a while, now when I'm looking deeper into it, for a chat aplication instead of sending message as client - server - client, there must be some possible ways for direct client to client message sending?
Browsers tend to communicate with servers via HTTP. Some implement other protocols, like websockets & SPDY, but again, these are mostly client-server protocols.
Some plug-ins (like Flash & Java) can open ports and communicate client-client. (AFAIK, haven't actually used them.)
Chrome is the only browser I'm aware of that can (soon) open TCP and UDP sockets from Javascript and do direct client-client communication. At the moment normal web apps can't do this, your app needs to be run as a "Chrome Packaged App", with a special manifest file.
Here are the docs, a blog post describing the feature and a browserify module that can behave like the net node.js module in the browser.
EDIT: This should probably not be tagged as [node.js] since you're trying to run in browsers (not in your node vm), this is a Javascript / Browser question.
This is maybe out of date question, but take a look on PeerJS.
It requires server only as a connection manager (broker). But all communication is done between clients directly.
This does not have anything with server. If you need something like that and if clients are flash you can use RTMFP . For JS i google this library which is js bridge for RTMFP, I dont know how it works. At the end you can write you own library to chat beetween clients but this is much harder(IP addresses are behind NAT, etc...)
I think answer for your question is here
PS Also exist open-source in-browser server which written using JS, but I didn't google it quickly. If you find it, please notify me.
If you just don't want to write your own server you can use:
https://httprelay.io
Use AJAX calls to communicate between peers.
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 :)
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.
We have a network camera. It has an HTTP server to provides the current image. There is also a Telnet interface for controlling the camera (i.e. trigger, focus, etc.). I would like to add an HTML page to the camera that would provide a simple interface (we already have client software we write). I can "GET" the image and display that, but I would also like to have controls that use the Telnet interface to control the camera. So a button might have JavaScript code behind it that connects to the camera via Telnet (logs in) and issues the command to trigger the camera.
I know that JavaScript/browsers support connecting to the same host via XMLHttpRequest. In this case I would be looking to open a socket on port 23 and send text. I also know that I can do this through Flash, Java, or some other technology, but I would prefer to use JavaScript only. If that is possible.
Thomaschaaf is correct, while HTML5 introduces websockets you'll find they still require special server support as they post HTTP style information upon opening the socket:
JS/HTML5 WebSocket: Connect without HTTP call
The best way, currently, to have true sockets is to either
use a flash or Java component on the webpage that does the actual socket work.
use a proxy server with websockets that can handle the additional protocol overhead of websockets and connect to the real tcp/ip port with plain sockets.
The jsterm example Matt linked does the latter, and if your webcans are behind a firewall it will not work in your situation without also implementing another server.
There are libraries that implement the first method, two are linked here for convenience, many others can be found using a search engine:
http://stephengware.com/proj/javasocketbridge/ (Java)
http://matthaynes.net/blog/2008/07/17/socketbridge-flash-javascript-socket-bridge/ (Flash)
jsTerm is an HTML5 implementation of a Telnet client.
You'll need a browser that supports HTML5 WebSockets. WebSockets is the only method of doing non-HTTP requests with pure JavaScript.
Currently there is no way to do socket connections with JavaScript only.
But what you are searching for is a socket connection ;)
https://developer.mozilla.org/en/XML_Extras
If I interpret the question liberally as "is there a remote connectivity library for Javascript", then the answer is yes (quoting from https://xtermjs.org/):
A web based SSH2 client using xterm.js, socket.io, and ssh2: https://github.com/billchurch/WebSSH2
HTML5 Based SSHv2 Web Client with E2E encryption utilising xterm.js, SJCL & websockets: https://github.com/stuicey/SSHy
I've tried WebSSH2 with node.js briefly, it worked for me - I managed to connect to a Linux-based server with it.
(I know this probably doesn't help the OP but this is a 7-year old question anyway. Maybe it helps others who are needing an answer to a similar problem.)