matijagaspar / ws-avc-player

Video player for browser that is able to play realtime low latency h264 video stream from websocket.
BSD 3-Clause "New" or "Revised" License
156 stars 48 forks source link

uwebsocket / SSL #4

Closed yenchuan88 closed 4 years ago

yenchuan88 commented 5 years ago

can it be use with https://github.com/uNetworking/uWebSockets.js or any way i can add ssl and https support, ssl are require at most of the website nowadays

matijagaspar commented 4 years ago

The example is using uws, but the lib itself does not really care about the ws lib you use as long as it has the somewhat standard interface:

https://github.com/matijagaspar/ws-avc-player/blob/master/example/index.js#L23

Websocket server is passed to the constructor, and the client is using the built in WS client https://javascript.info/websocket

This app has been tested over https with nginx acting as https reverse proxy. But you could also handle https directly on the server with express and uws

Alternatively you can not pass the ws handler, and avcServer.new_client(socket) yourself. Something like

App..ws('/*', {
   open: socket=>{
   const standardSocket = /* some code that makes the socket correctly handle events: on('message') and on('close), and send function */
   avcServer.new_client(standardSocket)
    }
})

Or just use the const { WebSocketServer } = require('@clusterws/cws'); as a replacement for the old 'uws'. in the example/index.js.

But I will look into setting the example to use the new uwebsocktes as it does make sense.

But regarding ssl, to be honest this server shouldn't really be directly exposed to web anyway and should probably sit behind a reverse proxy.