I hope you guys can spare a moment with some ideas on how to develop my idea.
I have an Asterisk-based telephone switch . When an incoming call is arriving, I can make sure the server runs an external script of any language.
Here comes my development work. I would like to notify a group of listening clients about the call, and probably open a browser page on their computer.
What kind of approach would you take for this sort of server-based push notification? (with no iPhone involved)
I am open to any language.
Thanks
You can use or build off a tool like callPopPy, which interacts with Asterisk's existing notification subsystem. More options are listed here.
Maybe have a look at www.pubnub.com .. its commercial, but lets you send 5 million messages a month for free. Essentially it lets you create a named channel, and have X number of clients connect to it and send messages back and forth.
Using one of these services would of course require you to write a client to distribute to your users (in your language of choice) and tie's you in somewhat (shouldn't really be a problem as you could swap in some other solution later if they go under or whatever.)
The upside would be, very good x-platform support and a very clean API, infrastructure taken care of for you (for example clients can still connect the the channel even if your asterisk box is down or whatever)
(and no, I don't work for pubnub! but it seems like a no-brainer to use it with the 5mil messages free deal!)
Related
I can best describe what I'm looking for with an example of a simplified version. One of the demos for Tornado is a simple chat server:
https://github.com/facebook/tornado/blob/master/demos/chat/chatdemo.py
I'm interested in the MessageMixin class here. It keeps a static-length backlog of messages, and when new messages are available, it returns the slice of the message list that's new. Or that's what it appears to do. I know that I've implemented something like that before when writing a simple comet app.
So has anyone generalized this and added fancy things to it? I'm particularly interested in a way to manage many channels of communication and delete ones that haven't been used in a while. Persistence might also be useful.
Is this something an MQ can do?
Redis has a publish/subscribe feature, along with additional data structure-oriented commands which you can use to persist and expire the message backlog, list users in a given room, or other attributes associated with them. The protocol is text-based and is a superset of the Memcached commands.
Here is a description which uses chat as an example of pub/sub along with a Ruby example using Websocket, and a snippet in Python which uses Websocket, Tornado and Redis pub/sub to implement a simple chat room.
Based on the information in your question, a dedicated message queue (like RabbitMQ) may also be useful to you. It is hard to say without knowing what you need in the areas of message volume, fault-tolerance, replication, etc. Redis may also be what you're looking for, but if nothing else it is pretty simple and could help you get a prototype running quickly to further nail down your app's requirements.
Mornink!
I need to design, write and implement wide system consisting of multiple unix servers performing different roles and running different services. The system must be bullet proof, robust and fast. Yeah, I know. ;) Since I dont know how to approach this task, I've decided to ask you for your opinion before I leave design stage. Here is how the workflow is about to flow:
users are interacting with website, where they set up demands for service
this demand is being stored (database?) and some kind of message to central system (clustered) is being sent about new demand in database/queue
central system picks up the demand and sends signals to various other systems (clusters) to perform their duties (parts of the demanded service setup)
when they are done, they send up message to central system or the website that the service is now being served
Now, what is the modern, robust, clean and efficient way of storing these requests in some kind of queue, and executing them? Should I send some signals, or should I let all subsystems check the queue/db of any sort for new data? What could be that queue, should it be a database? How to deal with the messages? I thought about opening single tcp connection and sending data over that, along with comands triggering actions/functions on the other end, but at closer inspection, there has to be other, better way. So I found Spring Python, that has been criticized for being so 90's-ish.
I know its a very wide question, but I really hope you can help me wrap my head around that design and not make something stupid here :)
Thanks in advance!
Some general ideas for you:
You could have a master-client approach. Requests would be inserted in the master, stored in a database. Master knows the state of each client (same db). Whenever there is a request, the master redirects it to a free client. The client reports back when has finished the task (including answers if any), making it able to receive a new task from the master (this removes the need for pooling).
Communication could be done using web-services. An HTTP request/post should solve every cases. No need to actually go down to the TCP level.
Just general ideas, hope they're useful.
There are a number of message queue technologies out there which are Python friendly which could serve quite well. The top two that I know of are ActiveMQ and RabbitMQ, which both play well with Python, plus I found this comparison which states that ActiveMQ currently (as of 18 months ago!) outperforms RabbitMQ.
I'm interested in something based on Jabber but I didn't find a free/opensource one so I'm thinking of writing one.
I've installed a Jabber server and now thinking about the ways in which I can write the client. I'm thinking of one of either these two methods.
1) An ajax call made to a jabber script running on the webserver that takes care of connecting to the server. But then I thought because of the dependencies involved in the jabber client, it might end up consuming too much memory when a few clients connect.
2) The other method is to run a client running as a daemon that takes care of all the heavy lifting. This way I need to have only one instance of the client that sends a spoofed message (sender's name as that of whatever the user entered on the site). A simple script running on the webserver talks to this daemon over some sort of API (XMLRPC or Msgpack maybe?)
I think #2 is better but I'm not sure. Are there other ways I can implement this? I'm considering using Perl or Python for this.
Jabber is usually called XMPP nowadays, and there are dozens of clients and servers, something for every language. If you are using Javascript (you mention Ajax), you probably want Strophe. Most servers are modular, so you only load the features you need (consider Tigase, ejabberd, or xmpppy). Writing your own is even worse an idea than it sounds.
BOSH
Install prosody because it is really eaSily installed and has BOSH support built-in. You could skip this but then you need to find out how to use BOSH via ejabberd.
use strophe.js to implement this(using BOSH). New browsers support cross-domain request(CORS -> read Proxy-less BOSH part). The old browsers you could use proxy or use flash in the middle as proxy.
read Professional XMPP Programming with JavaScript and jQuery to learn strophe. It even has chapters explaining how to create chat.
Node.js
Or you could consider installing node.js to create your chat system using socket.io.
I'm building a website where I hook people up so that they can anonymously vent to strangers. You either choose to be a listener, or a talker, and then you get catapulted into a one-on-one chat room.
The reason for the app's construction is because you often can't vent to friends, because your deepest vulnerabilities can often be leveraged against you later on. (Like it or not, this is a part of human nature. Sad.)
I'm looking for some insight into how I should architect everything. I found this neat tutorial, http://giantflyingsaucer.com/blog/?p=875, which suggests using python & stackless + flash. Someone else suggested I should try using p2p sockets, but I don't even know where to begin to look for info on that.
Any other suggestions? I'd like to keep it simple. :^)
Unless you expect super high load, this is simple enough that it doesn't really matter what you use on the backend: just pick something you're comfortable with. PHP, Python, Ruby, Even a bash script using CGI - your skill level with the language is likely to make more difference that the language features themselves.
I would use an XMPP server like ejabberd or OpenFire to power the backend. XMPP contains everything you need for creating chat/real-time applications. You can use a Flex/Flash Actionscript library like Actionscript 3 XIFF to communicate with the XMPP server.
Flash is user-unfriendly for UI (forms, etc) and it is relatively easy to do what you want using HTML and Javascript on the front-end.
One possible approach for reading the messages would be to regularly do an Ajax request from the server for any new messages. Format the new message and insert it into the DOM.
You will probably need to answer at least these questions before you continue, though:
1) Are you recreating IRQ (everyone sees your posts), or is this a random one-to-one chat, like chatroulette?
1a) Is this a way for a specific person to talk to another specific person, or is this more like twitter?
2) What is your plan for scaling up if this idea takes off? Memcached should probably be a method of last-resort ("bandaid over a bullet-hole"). What's your roadmap for eventually handling a large volume of messages?
3) Is there any way to ignore users? Talk to certain users? Hide your rants from users?
Hey Zach I had to create a socket server for a flash game I made. I built my server in C#, but I would use whatever language your familiar with. If you let me know what your most comfortable with I could try to help find a good tutorial.
The one thing I spent many hours on was getting flash to work from a website with a socket server. With the newer versions of Flash you need to send back a policy file. In my case this needed to be the first chunk of data sent back to the client when they connected to the socket server.
Not sure what to tell you about structuring the back end. I need to know a little bit more about your programming experience. I had an array of all user connections, and was placing them in different "Rooms" so they could play each other. So just some simple arrays and understanding how to send messages to the clients would help you here.
If you have any familiarity with C# I would have no problem sending you the source code for my socket server.
I'm trying to find out if there is a way I could embed a Python back-end into an AIR application? I'm looking to employ an approach similar to the one outlined here to implement the business logic for my application, but additionally, I would like to provide the user with a single binary which they can load. I don't want the user to have to fire up a seperate server process to make this work. Is this possible in some way or am I out of luck?
You cannot embed your Python server in an AIR application. So basically you are out of luck.
The simplest solution probably is to run a server on a central location that all your users can connect to from their AIR apps. That means that all/most of the data will be on your server, and not on the users computer, I don't know if that is a big issue but I guess it is.
Also depending on your target systems you could create the program you want yourself without (fully) depending on AIR. You can generate executables for windows and osx from Flash CS3/4 or you can use a special (commercial) executable-maker that provides some more functionality. Wrapping this exe and your python program in a meta-executable that launches both should be possible with some work. Of course you won't have the benefits if the AIR installer etc in this case.
OK, so since it didn't seem possible to go that way around, I came up with an alternative that seems to work for what I want.
Instead of trying to embed Python inside AIR, I've gone the other way around: I'm building my Python code into a stand-alone executable using PyInstaller and bundling the AIR application as a resource. The Python code then starts up it's webserver and fires off the AIR app which can then connect to the (local) remote services as required.
Probably. We are using a J2EE server side which uses SOAP webservices to talk to our AIR application on the frontend. You should be able to do the same because soap doesn't care which technology sits on either side of it.
You can always have the application launch from a single binary which first fires up the server, then the client, if both are expected to sit on the users system. Also it gives you flexibility to have a more service oriented model later, if you want to. Without knowing what your app does, it is hard to know if that makes sense or not.
For setting up the python side of SOAP webservices, here's a useful link to a diveintopython article. Then, if you have your server running with the wsdl, FlexBuilder can generate the AIR side of the webservices for you.