c++ - Async RestFul vs Websocket -


i implementing client-server api long job processing times (order of minutes in cases). of api calls short , respond coupe require back-end processing. using node.js web server. current implementaion follows -

client(browser) <-> node js <-> engine

the engine back-end process processes each job (c++ code). interactions http. now, traditionally implement long jobs async ajax/restful requests , short jobs sync restful requests.

i going have status updates long processing jobs (processing large data) - intermediate results, percent complete etc.

i loolking @ websockets alternative (and relatively new it). here questions -

  1. should websockets long jobs instead of async restful api (i love avoid handling client-timeouts, long-polling etc.) ?
  2. how moving requests websockets (why bother rest @ all? )
  3. in general, best practices implement architecture. (previously, worked on projects interaction between webserver , engine simple tcp connection custom commands.)

note:- not worried cross-browser support (especially older versions) right now.

i've implemented client-server api using websockets communicate between browser , c++ backend. library used libwebsockets http://git.warmcat.com/cgi-bin/cgit/libwebsockets/

both long running , simultaneous commands worked on websockets. multiple requests can sent client , server can respond when ready , can send responses out of order (or coalesce responses single response).

the timeout & long-polling stuff necessary ajax becomes simpler e.g. client disconnections can detected server when socket broken.

as best practices, based design on these articles. used json encode messages.

if server node.js socket.io. abstracts communication layer , can pick between ajax, websockets etc depending on what's available.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -