Thursday 15 March 2012

python - how can server initiate a connection to client -



python - how can server initiate a connection to client -

so created app app connects server , tells something. server takes lot of time thing (like hr or so). doesn't create sense connect client server long. want server must create connection client inform ready deliver end result. after connection, sends info client.

i thinking 2 ideas here:

i can create server on client side also, , client can hear server connect. clients desktop apps or mobile apps limited resources , of them behind firewall/nat. if have server running, not sure main server able connect them.

the client can maintain checking periodically whether results prepared or not. way client not have maintain server or anything. plain old client server architecture. costs me lot of un-necessary traffic, result may available within few minutes few hours. client pining server not seems me.

i first of have no thought start or google stuff. i know such thing exists because see time servers such "skype" informs desktop app have new friend request, or gmail notification scheme google shows message on desktop when new mail service received.

most google searches yielding same stuff client connects server. case opposite here.

if question not upto standard, few references great, , delete post. there's great chance not thinking , beingness stupid. please help. thanks.

so after researched lot of related articles, here have come with.

these links describe called "server push" pushes info client server. there variety of methods discussed here. point #2 near solution, , term point #2 called long polling.

http://en.wikipedia.org/wiki/push_technology http://mrjoes.github.io/2013/06/21/python-realtime.html http://flask.pocoo.org/snippets/80/

but methods discussed in both of these articles pushing info web browser. in cases, solution can extended server force in mobile clients, still reading on them, can't comment much.

however, server app push, kind of requirement was, 2 things stood up:

redis pub/sub: functionality of pub/sub channels in redis wonderful. have subscribe clients channel in server, , anytime server publishes something, clients automatically hear that. redis used, maintained, easy use, , designed big scale applications. liked that. amazon sns. people me (i forgot mention in question, using amazon servers) using amazon aws, feature sns (simple notification system) designed entire server app push. cheap, easy implement , comes python libraries use. if don't want in redis, utilize simple tool amazon force info clients. supports force info straight sqs (simple queue service), if ever need it.

i have decided go amazon sns , maintain learning redis side side, future use.

update:

need server push? forget else , utilize redis + socket-io + node-js. how did not know websockets. next best thing.

in app, send messages redis want pushed clients. redis publishes messages. socket.io listening on channels using psubscribe hear on patterns rather 1 channel. category of user defined channel name.

once socket.io (written in node.js) hears message, emit messages client. clients inturn listening socket.io on specific port. socket.io supports rooms channel in redis.

for live examples google real time chat socket.io , node.js.

i write examples if requests me to. real easy.

python python-3.x client-server

No comments:

Post a Comment