GithubHelp home page GithubHelp logo

versatica / protoo Goto Github PK

View Code? Open in Web Editor NEW
165.0 12.0 48.0 511 KB

Minimalist and extensible Node.js signaling framework for multi-party Real-Time applications

Home Page: https://protoo.versatica.com

License: MIT License

JavaScript 100.00%
nodejs node-module signaling websocket client-side server-side

protoo's People

Contributors

aetheon avatar ibc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protoo's Issues

Proposal: Websocket emulation server & transport

Appreciate everything the group has done.

It seems like this project is evolving into a nice alternative to socket.io for a websocket transport.

I'm not sure what the roadmap looks like in regards to adding other sorts of servers/transports (similar to SocksJS), but if there's any way to add this into this library, it would be useful.

Having something like:

  const protooXhrPollingServer = new protoo.XhrPollingServer(httpServer, options);

would be awesome.. Thanks for your time!

Feature request: Do not attempt to reconnect

I've put some authorization logic inside protoo server. When auth fails, client still tries to connect again, which isn't what I want.

At the same time, once client gets connected and connection is lost, I want it to try to reconnect.

prooto-client - ability to disable node-retry

Hi guys,

At the moment protoo-client always auto retries WS connections due to wasConnected check here.

The only way around this is to try to set _closed true here.

Would you guys willing to accepts PRs to disable the usage of node-retry when creating WebSocketTransport?

The main reason is that for code maintenance, using event callback events can become hard to maintain. An example is when a mediasoup transport fails when connecting to a VPN during a call and the WS keeps the connection alive.

Tks.

Couple of typos

Thanks for this delightful lib! It was a breeze to set up and I'm looking forward to using it in everything.

I noticed a couple of small errors in the example code on https://protoojs.org:

The websocketserver example says

const server = new protooServer.WebSocketServer.Room(httpServer, options);

but there is no Room method; protooServer.WebSocketServer is the constructor.

The connectionrequest example should say await instead of async.

Protoo request unable to send Map.

I am trying to send a Map as a part of an object from protoo request from frontend, to the backend where protoo request is being handled, but on logging the data on backend, the map being received inside the object is empty.

Other fields come fine, which are String and int types.

Consider fast-reconnection as a non-disconnection

In websites it's so common to have a chat widget and the user to be able to detach it into a separate browser window. That operation involves a fast WS disconnection followed by a new connection with same data.

Protoo server should let time span for such a fast-reconnection without emitting both "offline" and "online". It should be a new setting into the Application.

Uncaught TypeError: _this2.listenerCount is not a function

My package.json file:
"protoo-client": "^3.0.0"

Browse will report error: "Uncaught TypeError: _this2.listenerCount is not a function"
bellow code report error:
if (_this2.listenerCount('message') === 0) {
logger.error('no listeners for WebSocket "message" event, ignoring received message');

return;

}

I want encryption

For some security projects, I hope to support the communication encryption function。Of course, this is just a suggestion

Peer disconnects randomly and reconnects afterwards

I just started trying protoo and got random disconnect/reconnect (close/open) events fired on the client peer (same on the server side peer). Just trying to figure out if it's something I'm missing out or it's just a bug.

My client side app strongly relies on the peer "open" event, which as i said, fires multiple times because of the random "reconnection" behaviour.

If you don't know what im talking about I'll provide you with the code I'm using.
This is my console atm.

protoo-wtf

Have I missed some configuration?

Thank you very much for your work.

Since updating from Debian 9 to Debian 11 there is a problem that crashes after 10 hours or 20 hours

I was using this https://github.com/meething/meething-mediasoup project on a Debian 9 and it was working fine, but since I upgraded Debian 11 there is a crash which happens almost every 10h or 20h

This crash is quite painful, it is for a production server

Here is the error :

_createConsumer() | failed:Error: TypeError: Cannot read properties of null (reading 'consume')
    at Peer._handleResponse (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:282:18)
    at WebSocketTransport.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:214:10)
    at WebSocketTransport.emit (node:events:390:28)
    at WebSocketTransport.safeEmit (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/EnhancedEventEmitter.js:18:9)
    at WebSocketConnection.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/transports/WebSocketTransport.js:129:9)
    at WebSocketConnection.emit (node:events:390:28)
    at WebSocketConnection.processFrame (/home/debian/node/mediasoup/meething-mediasoup/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /home/debian/node/mediasoup/meething-mediasoup/node_modules/websocket/lib/WebSocketConnection.js:323:40
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  [stack]: "Error: TypeError: Cannot read properties of null (reading 'consume')\n" +
    '    at Peer._handleResponse (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:282:18)\n' +
    '    at WebSocketTransport.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:214:10)\n' +
    '    at WebSocketTransport.emit (node:events:390:28)\n' +
    '    at WebSocketTransport.safeEmit (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/EnhancedEventEmitter.js:18:9)\n' +
    '    at WebSocketConnection.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/transports/WebSocketTransport.js:129:9)\n' +
    '    at WebSocketConnection.emit (node:events:390:28)\n' +
    '    at WebSocketConnection.processFrame (/home/debian/node/mediasoup/meething-mediasoup/node_modules/websocket/lib/WebSocketConnection.js:554:26)\n' +
    '    at /home/debian/node/mediasoup/meething-mediasoup/node_modules/websocket/lib/WebSocketConnection.js:323:40\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:78:11)',
  [message]: "TypeError: Cannot read properties of null (reading 'consume')",
  code: 500
}
_createConsumer() | failed:Error: request timeout
    at Timeout._onTimeout (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:156:14)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7) {
  [stack]: 'Error: request timeout\n' +
    '    at Timeout._onTimeout (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:156:14)\n' +
    '    at listOnTimeout (node:internal/timers:557:17)\n' +
    '    at processTimers (node:internal/timers:500:7)',
  [message]: 'request timeout'
}
request failed:Error: producer with id "e509edbb-5687-4003-94fe-b71eb325edaf" not found
    at ConfRoom._handleProtooRequest (/home/debian/node/mediasoup/meething-mediasoup/lib/Room.js:222:17)
    at Peer.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/lib/Room.js:58:12)
    at Peer.emit (node:events:390:28)
    at Peer._handleRequest (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:224:9)
    at WebSocketTransport.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:212:10)
    at WebSocketTransport.emit (node:events:390:28)
    at WebSocketTransport.safeEmit (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/EnhancedEventEmitter.js:18:9)
    at WebSocketConnection.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/transports/WebSocketTransport.js:129:9)
    at WebSocketConnection.emit (node:events:390:28)
    at WebSocketConnection.processFrame (/home/debian/node/mediasoup/meething-mediasoup/node_modules/websocket/lib/WebSocketConnection.js:554:26) {
  [stack]: 'Error: producer with id "e509edbb-5687-4003-94fe-b71eb325edaf" not found\n' +
    '    at ConfRoom._handleProtooRequest (/home/debian/node/mediasoup/meething-mediasoup/lib/Room.js:222:17)\n' +
    '    at Peer.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/lib/Room.js:58:12)\n' +
    '    at Peer.emit (node:events:390:28)\n' +
    '    at Peer._handleRequest (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:224:9)\n' +
    '    at WebSocketTransport.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:212:10)\n' +
    '    at WebSocketTransport.emit (node:events:390:28)\n' +
    '    at WebSocketTransport.safeEmit (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/EnhancedEventEmitter.js:18:9)\n' +
    '    at WebSocketConnection.<anonymous> (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/transports/WebSocketTransport.js:129:9)\n' +
    '    at WebSocketConnection.emit (node:events:390:28)\n' +
    '    at WebSocketConnection.processFrame (/home/debian/node/mediasoup/meething-mediasoup/node_modules/websocket/lib/WebSocketConnection.js:554:26)',
  [message]: 'producer with id "e509edbb-5687-4003-94fe-b71eb325edaf" not found'
}
/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:156
					pReject(new Error('request timeout'));
					        ^

Error: request timeout
    at Timeout._onTimeout (/home/debian/node/mediasoup/meething-mediasoup/node_modules/protoo-server/lib/Peer.js:156:14)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

Is this a problem with protoo-server or mediasoup or meething-mediasoup?

package.json :

{
  "name": "meething-mediasoup",
  "version": "1.0.2",
  "description": "",
  "scripts": {
    "start": "nodemon ./main.js ./lib"
  },
  "dependencies": {
    "mediasoup": "^3.7.9",
    "protoo-server": "^4.0.6",
    "quick-lru": "^5.1.0",
    "stun": "^2.1.0"
  },
  "devDependencies": {
    "nodemon": "^1.19.1"
  }
}

crash bug

It's hard to repeat the bug, but it sometimes happens. It happen one time in 2 days nearly.

2024-02-28T03:46:13.286Z protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[114.254.0.69]:53390, error:Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}]
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on TLSSocket instance at:
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}

after the log above show, the node crash. It seems one exception is not handled by try...catch.
node version:

node --version
v21.5.0

Plans to support multiple rooms?

Right now looking at the documentation and code it is unclear how to use multiple rooms. There is also no way to distinguish them in the Room object (no id or name).

Infinite loop error when WS closed

This just happened, producing an infinite loop (kill -9 required):

  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +1ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +1ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +21ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +1ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +1ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms
  protoo-server:ERROR:WebSocketTransport connection "error" event [conn:WSS:[192.168.1.33]:55930, error:Error: This socket has been ended by the other party] +0ms

Allow reject(error)

Allow calling reject(error) being error an instance of Error. In that case, do this:

reject(503, error.toString());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.