sessionId error 409

Hi,
I am new to openvidu and this is my first implementation.
I have server working properly and the examples work fine.

I am working with Django on the backend but I have a problem creating the sessions.

In the examples I see that a session can be created with a “custom session id”, but if I repeat it, I get error 409 (documentation explains that id must be unique).

How can I set the Room Name for other users to connect to the same room?
Who sets the Room Name parameter?

Thank you so much

The session only needs to be created once that’s why you’re getting a 409. After the creation of the session you must create a connection, get the token of that connection, and send the token of that connection to your users to be used by openvidu-browser.

Here you have explained how to do it: https://docs.openvidu.io/en/2.16.0/cheatsheet/join-session/

If you’re using django, you should check API REST docs.

Best Regards,
Carlos.

Thank you very much Carlos for your help.
As I understand it, then:
Let’s suppose that “User A” accesses, creates his random session Id “ses_ABC1234”, I get the token correctly and make the connection. I am already watching the video correctly.
Now access “User B”:
Do I have to create a new session, or does it use “User A”?
Does he have to use the same token as User A or do I generate a new token using the “User A” session?

I think my main question is in the use of session: Does it refer to the Room or the User? One session for everyone in the same room?

Yes, for Django I tried first with the “pyopenvidu” package, but finally I’m making API calls directly.

Muchas gracias y un saludo

Yes, it is one session for everyone in the same room.

You need to create a connection for each user which want to join the session. This rest api call returns a Connection Object which have, as you can see, an attribute called token. This token should be send to the browser client.

TLDR: Each new user who wants to join a session, should call your backend, and your backend do the API Rest call to create a connection, and then return the token to this specific browser client who wants to join.

Regards!

BTW check this tutorials. Even if it is in a different language than Python, i think they’re understandable for other languages too, and the logic is similar. You just need to make API Rest requests:


@cruizba, thank you for the explanation, i’ve faced this question too. One moment confuses me:
as i understand, connection can have only one person who connects to it and receives token, correct?

I’m using a node.js API, where Connection | OpenVidu Node Client - v2.19.0 – returns an array of publishers, which presumes that connection can have many connectors.
And there is no method for connection in node.js API to add publisher/subscriber.
Could you elaborate on that?
Thanks in advance!

API is future-proved to allow more than 1 Publisher per Connection, but right now it can only be 1 Publisher per Connection.

So right now 1 Session can have many Connections. 1 Connection can have 1 Publisher. 1 Connection can have many Subscribers.

Got it, thank you @pabloFuente !

1 Like