简体   繁体   中英

Low Latency communication using web sockets & Java Server

I'm looking to establish a low latency 2way communication between a javascript interface (client) and a java server.

The client has to request data from the server (can ask for different set's of data, needs to be async, data are small sets of sensor data).

I was thinking of implementing this using websockets because of it's low latency. However I'm stuck at choosing a java websocket server implementation (I found jetty but there are so many, and there is also a case to be made for node.js and socket.io but there are not going to be a lot of clients in this case; just one client sending multiple requests so correct me if i'm wrong but there doesn't seem to be a reason for going the node.js path).

Last but not least; the server is running on a raspberry pi and is recieving it's sensor data over a special protocol; (but i don't think that's important for this question).

Is there anyone with some experience in this field and wants to share his/her toughts? Thx.

I've been using Kaazing (HTML5 edition) to proxy traffic received via a web-socket to a Java process listening on a traditional TCP server socket.

It's working well, latency is low and was consistently handling over 1000 messages/second (though we found our Java code was the limiting factor in that respect).

Kaazing also provides client APIs for Java, JavaScript and Flex, which allowed us to write an acceptance test suite using the familiar APIs (Concordion in my case).

I don't know how well it'd run on a Raspberry Pi, but given it's free to download there's a simple way to find out.

I've solved my problem by using Atmosphere which is a framework that provides compatibility to all major java servers and web browsers. (The Java Official Standard is still in the workings).

https://github.com/Atmosphere/atmosphere

I've got the chat demo up and running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM