Multiplexing channels in a websocket

B3NW picture B3NW · Jul 20, 2015 · Viewed 7.5k times · Source

I'm developing an application where I need real-time communication and file upload. I'd preferably like to do it over a single connection with multiplexed channels. I see there is a an extension to the websocket protocol to allow multiplexing but I don't think there is yet browser support, if there is.. I have no idea how to use it.

I'm wanting to develop the server in java. The node server for socketio had a weird bug with namespaces and the java server for it didn't work correctly with namespaces.

I want a simple multiplexing system so that I can send some json and binary at the same time. Is there something existing for this or do I need to create something myself, if so.. where do I start?

Answer

Frank Zhang picture Frank Zhang · Nov 8, 2016

One thing i want to point out is Multiplexing is not about supporting multiple message formats, since webSocket doesn't specify the body format, so it's similar to HTTP, you can send JSON, picture, binary... anything you want.

Multiplexing is about how to re-use one connection channel to support multiple communications (similar concept in telecommunications), this is usually being used in scenario where multiple modules need websocket communication, but only one connection is allowed (like SocketJS), then we can employ Multiplexing tech to save the world.

More information please see: https://github.com/sockjs/websocket-multiplex https://www.rabbitmq.com/blog/2012/02/23/how-to-compose-apps-using-websockets/