3

I need to send image to client whenever it's available in the server. The client is not a browser but some kind of device(linux box) behind NAT (3G network) that will get the image as a file, write it to disk then display it in a screen (no browser here).

I'm new to nodejs and websocket.

Can I use a nodejs as a websocket client in the device and a nodejs as a server? Can you provide an example of using nodejs to execute a websocket client?

In this case, can nodejs detect 3G network loss then resume or restart the websocket?

What happen if connection loss happen while nodejs server is pushing an image to the device nodejs (client)? is there any resume solution?

how about Binary Js to handle file transfer between the 2 nodejs?

Can I do that with some pub/sub mecanism using a MOM like ActiveMQ?

1 Answer 1

3

Socket.io (which is probably what you'll want to use server-side) has a client module that works in node. It handles maintaining a connection to the server.

What you'll probably want to do is not push the image itself over the WebSocket connection. Instead, send a "new image available" notification message over the WebSocket, and when the client receives the message, make a regular HTTP GET request to the server to download the image.

Since you're making a regular HTTP request, you can use the Range header if you need to resume an interrupted download.

2
  • Thanks. and For the Range header, is there something to do in nodejs server to make it support this or nodejs will know where to resume? and if I want to have some web console to monitor transfers in real time with a resubmite button, what kind of modules or framework do I need with nodejs (server side and client side)?
    – SemBY
    Commented Aug 21, 2013 at 18:58
  • Connect/Express' res.sendfile() (and the static middleware) support Range.
    – josh3736
    Commented Aug 21, 2013 at 19:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.