New to Autobahn - Confused about Session.ID

#1

Hi,

I am new to Crossbar.io and Autobahn.js. I am unable to figure out how to discern different clients via a session ID.

Here is the portion of the config file that points to the nodejs:

{
“type”: “guest”,
“executable”: “node”,
“arguments”: [“server.js”],
“options”: {
“workdir”: “…/nodejs”
}

I am guessing that session.id is referring to the process that relates to the connection to crossbar itself. Is there a way to retrieve an ID that relate to different clients / browser tabs?

Kind Regards,
Reda

0 Likes

#2

Hi!

Welcome to using Crossbar & Autobahn!

The session ID is an integer assigned by Crossbar at the time of session establishment, and is uniquely identifying for the client during the session lifetime. After a session ends, its session ID may be assigned to a subsequently connecting session. (Since it’s a long integer, cases of this will be relatively rare in practice.)

The session ID can be accessed from within the client (browser or NodeJS) as a property of the session object, e.g. session.id (which returns the integer).

You can then use the session ID e.g. for receiver black- or whitelisting, i.e. limiting who receives a publication.

Hope this helps!

Regards,

Alex

···

Von: autob...@googlegroups.com [mailto:autob...@googlegroups.com] Im Auftrag von redabo...@gmail.com
Gesendet: Donnerstag, 16. Oktober 2014 23:14
An: autob...@googlegroups.com
Betreff: New to Autobahn - Confused about Session.ID

Hi,

I am new to Crossbar.io and Autobahn.js. I am unable to figure out how to discern different clients via a session ID.

Here is the portion of the config file that points to the nodejs:

{
“type”: “guest”,
“executable”: “node”,
“arguments”: [“server.js”],
“options”: {
“workdir”: “…/nodejs”
}

I am guessing that session.id is referring to the process that relates to the connection to crossbar itself. Is there a way to retrieve an ID that relate to different clients / browser tabs?

Kind Regards,
Reda


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to autob...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/201cd9d9-0625-4e7d-bb0b-992f6bdeb4f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#3

Hello,

Thank you. Your explanation makes perfect sense and coincides with the way I expected session.id to work.
There must be a mistake in the way I am using it. The code below always returns the same ID on all of my browser tabs. Even different browser instances return the same session.id.

Your assistance would be greatly appreciated.

Here is the server code:
var autobahn = require(‘autobahn’);
var crypto = require(‘crypto’);

var connection = new autobahn.Connection({
url: ‘ws://localhost:8080/ws’,
realm: ‘realm1’}
);

connection.onopen= function (session) {
function createToken() {
console.log(session.id);
return crypto.randomBytes(32).toString(‘hex’);
}

session.register('com.tarot.createToken', createToken).then(
    function (registration) {
        console.log("Procedure registered:", registration.id);
    },
    function (error) {
        console.log("Registration failed:", error);
    }
);

};

connection.onclose = function(reason, details){
console.log(“Client Disconnected!”);
}

connection.open();

``

This is the console output I get in the console using 3 tabs in two different browsers on the same machine:

2014-10-17 11:08:29+0100 [Guest 17938] Procedure registered: 2992382140210677
2014-10-17 11:08:33+0100 [Guest 17938] 6095189252032380
2014-10-17 11:08:39+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:31+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:54+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:02+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:17+0100 [Guest 17938] 6095189252032380

Kind Regards Borchardt

···

On Friday, 17 October 2014 10:46:52 UTC+1, Alexander Gödde wrote:

Hi!

Welcome to using Crossbar & Autobahn!

The session ID is an integer assigned by Crossbar at the time of session establishment, and is uniquely identifying for the client during the session lifetime. After a session ends, its session ID may be assigned to a subsequently connecting session. (Since it’s a long integer, cases of this will be relatively rare in practice.)

The session ID can be accessed from within the client (browser or NodeJS) as a property of the session object, e.g. [session.id](http://session.id) (which returns the integer).

You can then use the session ID e.g. for receiver black- or whitelisting, i.e. limiting who receives a publication.

Hope this helps!

Regards,

Alex

Von: auto...@googlegroups.com [mailto:autob...@googlegroups.com] Im Auftrag von reda...@gmail.com
Gesendet: Donnerstag, 16. Oktober 2014 23:14
An: auto...@googlegroups.com
Betreff: New to Autobahn - Confused about Session.ID

Hi,

I am new to Crossbar.io and Autobahn.js. I am unable to figure out how to discern different clients via a session ID.

Here is the portion of the config file that points to the nodejs:

{
“type”: “guest”,
“executable”: “node”,
“arguments”: [“server.js”],
“options”: {
“workdir”: “…/nodejs”
}

I am guessing that session.id is referring to the process that relates to the connection to crossbar itself. Is there a way to retrieve an ID that relate to different clients / browser tabs?

Kind Regards,
Reda


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to auto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/201cd9d9-0625-4e7d-bb0b-992f6bdeb4f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#4

Just to clarify. I am not referring to the console outputs in the browsers. I am only interested in the server giving me session.id’s for each browser instance connecting.

···

On Friday, 17 October 2014 11:17:15 UTC+1, reda...@gmail.com wrote:

Hello,

Thank you. Your explanation makes perfect sense and coincides with the way I expected session.id to work.
There must be a mistake in the way I am using it. The code below always returns the same ID on all of my browser tabs. Even different browser instances return the same session.id.

Your assistance would be greatly appreciated.

Here is the server code:
var autobahn = require(‘autobahn’);
var crypto = require(‘crypto’);

var connection = new autobahn.Connection({
url: ‘ws://localhost:8080/ws’,
realm: ‘realm1’}
);

connection.onopen= function (session) {
function createToken() {
console.log(session.id);
return crypto.randomBytes(32).toString(‘hex’);
}

session.register('com.tarot.createToken', createToken).then(
    function (registration) {
        console.log("Procedure registered:", registration.id);
    },
    function (error) {
        console.log("Registration failed:", error);
    }
);

};

connection.onclose = function(reason, details){
console.log(“Client Disconnected!”);
}

connection.open();

``

This is the console output I get in the console using 3 tabs in two different browsers on the same machine:

2014-10-17 11:08:29+0100 [Guest 17938] Procedure registered: 2992382140210677
2014-10-17 11:08:33+0100 [Guest 17938] 6095189252032380
2014-10-17 11:08:39+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:31+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:54+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:02+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:17+0100 [Guest 17938] 6095189252032380

Kind Regards Borchardt

On Friday, 17 October 2014 10:46:52 UTC+1, Alexander Gödde wrote:

Hi!

Welcome to using Crossbar & Autobahn!

The session ID is an integer assigned by Crossbar at the time of session establishment, and is uniquely identifying for the client during the session lifetime. After a session ends, its session ID may be assigned to a subsequently connecting session. (Since it’s a long integer, cases of this will be relatively rare in practice.)

The session ID can be accessed from within the client (browser or NodeJS) as a property of the session object, e.g. [session.id](http://session.id) (which returns the integer).

You can then use the session ID e.g. for receiver black- or whitelisting, i.e. limiting who receives a publication.

Hope this helps!

Regards,

Alex

Von: auto...@googlegroups.com [mailto:autob...@googlegroups.com] Im Auftrag von reda...@gmail.com
Gesendet: Donnerstag, 16. Oktober 2014 23:14
An: auto...@googlegroups.com
Betreff: New to Autobahn - Confused about Session.ID

Hi,

I am new to Crossbar.io and Autobahn.js. I am unable to figure out how to discern different clients via a session ID.

Here is the portion of the config file that points to the nodejs:

{
“type”: “guest”,
“executable”: “node”,
“arguments”: [“server.js”],
“options”: {
“workdir”: “…/nodejs”
}

I am guessing that session.id is referring to the process that relates to the connection to crossbar itself. Is there a way to retrieve an ID that relate to different clients / browser tabs?

Kind Regards,
Reda


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to auto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/201cd9d9-0625-4e7d-bb0b-992f6bdeb4f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#5

Hi!

The session ID is for the session through which the client is connected to Crossbar, i.e. for your code it is for the session connecting your sever to Crossbar. This session does not change because other clients (the browsers) connect to Crossbar, so you get back the same session ID each time.

To get the session ID of the connected clients, I currently see two ways:

-          You use the metaevent “wamp.metaevent.session.on_join” which is fired each time a client joins. Your backend subscribes to this, and you get an event which contains the session ID.

  •      Since this only notifies you that a client has connected, but not who that client is, you may want to implement something like this yourself. This could be via PubSub, i.e. your backend subscribes to a connection event, e.g. “com.tarot.client_joined”, and each client, on connecting, publishes to this and includes any extra information as the publication payload, or it could be via RPC, where the client calls a method on your backend. The latter would also make it easy to return any information the backend needs the client to know (e.g. the token you’re creating in your code below).
    

Hope this helps – else just contact me again!


Regards,


Alex

···

Von: autob...@googlegroups.com [mailto:autob...@googlegroups.com] Im Auftrag von redabo...@gmail.com
Gesendet: Freitag, 17. Oktober 2014 12:31
An: autob...@googlegroups.com
Betreff: Re: New to Autobahn - Confused about Session.ID

Just to clarify. I am not referring to the console outputs in the browsers. I am only interested in the server giving me session.id’s for each browser instance connecting.

On Friday, 17 October 2014 11:17:15 UTC+1, reda...@gmail.com wrote:

Hello,

Thank you. Your explanation makes perfect sense and coincides with the way I expected session.id to work.
There must be a mistake in the way I am using it. The code below always returns the same ID on all of my browser tabs. Even different browser instances return the same session.id.

Your assistance would be greatly appreciated.

Here is the server code:

var autobahn = require(‘autobahn’);
var crypto = require(‘crypto’);

var connection = new autobahn.Connection({
url: ‘ws://localhost:8080/ws’,
realm: ‘realm1’}
);

connection.onopen= function (session) {
function createToken() {
console.log(session.id);
return crypto.randomBytes(32).toString(‘hex’);
}

session.register('com.tarot.createToken', createToken).then(
    function (registration) {
        console.log("Procedure registered:", registration.id);
    },
    function (error) {
        console.log("Registration failed:", error);
    }
);

};

connection.onclose = function(reason, details){
console.log(“Client Disconnected!”);
}

connection.open();

This is the console output I get in the console using 3 tabs in two different browsers on the same machine:

2014-10-17 11:08:29+0100 [Guest 17938] Procedure registered: 2992382140210677
2014-10-17 11:08:33+0100 [Guest 17938] 6095189252032380
2014-10-17 11:08:39+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:31+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:54+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:02+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:17+0100 [Guest 17938] 6095189252032380

Kind Regards Borchardt

On Friday, 17 October 2014 10:46:52 UTC+1, Alexander Gödde wrote:

Hi!

Welcome to using Crossbar & Autobahn!

The session ID is an integer assigned by Crossbar at the time of session establishment, and is uniquely identifying for the client during the session lifetime. After a session ends, its session ID may be assigned to a subsequently connecting session. (Since it’s a long integer, cases of this will be relatively rare in practice.)

The session ID can be accessed from within the client (browser or NodeJS) as a property of the session object, e.g. [session.id](http://session.id) (which returns the integer).

You can then use the session ID e.g. for receiver black- or whitelisting, i.e. limiting who receives a publication.

Hope this helps!

Regards,

Alex

Von: auto...@googlegroups.com [mailto:auto...@googlegroups.com] Im Auftrag von reda...@gmail.com
Gesendet: Donnerstag, 16. Oktober 2014 23:14
An: auto...@googlegroups.com
Betreff: New to Autobahn - Confused about Session.ID

Hi,

I am new to Crossbar.io and Autobahn.js. I am unable to figure out how to discern different clients via a session ID.

Here is the portion of the config file that points to the nodejs:

{
“type”: “guest”,
“executable”: “node”,
“arguments”: [“server.js”],
“options”: {
“workdir”: “…/nodejs”
}

I am guessing that session.id is referring to the process that relates to the connection to crossbar itself. Is there a way to retrieve an ID that relate to different clients / browser tabs?

Kind Regards,
Reda


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobah...@googlegroups.com.
To post to this group, send email to auto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/201cd9d9-0625-4e7d-bb0b-992f6bdeb4f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to autob...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/8c4a6517-89cb-4c2d-bb70-7278c231a826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#6

Hi,

This makes sense. Thank you very much for your help.

Kind Regards,
Reda

···

On Friday, 17 October 2014 13:27:57 UTC+1, Alexander Gödde wrote:

Hi!

The session ID is for the session through which the client is connected to Crossbar, i.e. for your code it is for the session connecting your sever to Crossbar. This session does not change because other clients (the browsers) connect to Crossbar, so you get back the same session ID each time.

To get the session ID of the connected clients, I currently see two ways:

-          You use the metaevent “wamp.metaevent.session.on_join” which is fired each time a client joins. Your backend subscribes to this, and you get an event which contains the session ID.
-          Since this only notifies you that a client has connected, but not who that client is, you may want to implement something like this yourself. This could be via PubSub, i.e. your backend subscribes to a connection event, e.g. “com.tarot.client_joined”, and each client, on connecting, publishes to this and includes any extra information as the publication payload, or it could be via RPC, where the client calls a method on your backend. The latter would also make it easy to return any information the backend needs the client to know (e.g. the token you’re creating in your code below).
 
Hope this helps – else just contact me again!
 
Regards,
 
Alex

Von: auto...@googlegroups.com [mailto:autob...@googlegroups.com] Im Auftrag von reda...@gmail.com
Gesendet: Freitag, 17. Oktober 2014 12:31
An: auto...@googlegroups.com
Betreff: Re: New to Autobahn - Confused about Session.ID

Just to clarify. I am not referring to the console outputs in the browsers. I am only interested in the server giving me session.id’s for each browser instance connecting.

On Friday, 17 October 2014 11:17:15 UTC+1, reda...@gmail.com wrote:

Hello,

Thank you. Your explanation makes perfect sense and coincides with the way I expected session.id to work.
There must be a mistake in the way I am using it. The code below always returns the same ID on all of my browser tabs. Even different browser instances return the same session.id.

Your assistance would be greatly appreciated.

Here is the server code:

var autobahn = require(‘autobahn’);
var crypto = require(‘crypto’);

var connection = new autobahn.Connection({
url: ‘ws://localhost:8080/ws’,
realm: ‘realm1’}
);

connection.onopen= function (session) {
function createToken() {
console.log(session.id);
return crypto.randomBytes(32).toString(‘hex’);
}

session.register('com.tarot.createToken', createToken).then(
    function (registration) {
        console.log("Procedure registered:", registration.id);
    },
    function (error) {
        console.log("Registration failed:", error);
    }
);

};

connection.onclose = function(reason, details){
console.log(“Client Disconnected!”);
}

connection.open();

This is the console output I get in the console using 3 tabs in two different browsers on the same machine:

2014-10-17 11:08:29+0100 [Guest 17938] Procedure registered: 2992382140210677
2014-10-17 11:08:33+0100 [Guest 17938] 6095189252032380
2014-10-17 11:08:39+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:31+0100 [Guest 17938] 6095189252032380
2014-10-17 11:12:54+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:02+0100 [Guest 17938] 6095189252032380
2014-10-17 11:13:17+0100 [Guest 17938] 6095189252032380

Kind Regards Borchardt

On Friday, 17 October 2014 10:46:52 UTC+1, Alexander Gödde wrote:

Hi!

Welcome to using Crossbar & Autobahn!

The session ID is an integer assigned by Crossbar at the time of session establishment, and is uniquely identifying for the client during the session lifetime. After a session ends, its session ID may be assigned to a subsequently connecting session. (Since it’s a long integer, cases of this will be relatively rare in practice.)

The session ID can be accessed from within the client (browser or NodeJS) as a property of the session object, e.g. [session.id](http://session.id) (which returns the integer).

You can then use the session ID e.g. for receiver black- or whitelisting, i.e. limiting who receives a publication.

Hope this helps!

Regards,

Alex

Von: auto...@googlegroups.com [mailto:auto...@googlegroups.com] Im Auftrag von reda...@gmail.com
Gesendet: Donnerstag, 16. Oktober 2014 23:14
An: auto...@googlegroups.com
Betreff: New to Autobahn - Confused about Session.ID

Hi,

I am new to Crossbar.io and Autobahn.js. I am unable to figure out how to discern different clients via a session ID.

Here is the portion of the config file that points to the nodejs:

{
“type”: “guest”,
“executable”: “node”,
“arguments”: [“server.js”],
“options”: {
“workdir”: “…/nodejs”
}

I am guessing that session.id is referring to the process that relates to the connection to crossbar itself. Is there a way to retrieve an ID that relate to different clients / browser tabs?

Kind Regards,
Reda


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to auto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/201cd9d9-0625-4e7d-bb0b-992f6bdeb4f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to auto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/8c4a6517-89cb-4c2d-bb70-7278c231a826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 Likes