active connections, handle users

#1

Hi,

I’m new to crossbar, and not sure exacly what I’m doing, but…

I’ve created object that store my users (name, id, session_id) and want to add session_id to user when he connect’s and remove it when he leave / disconnect for any reason .

so i created procedure that I call when user login, also I add

def onLeave(self, details) and def onDisconnect(self) but even if I close my app window that is connected those methods are never called ;(

I also added to my config:

“options”: {

“auto_ping_interval”: 1000,

“auto_ping_timeout”: 2000,

“auto_ping_size”: 4

}

but this is not helping.

what is the proper way to trace my connected clients and know when they disconnect?

0 Likes

#2

I even try to print call(“wamp.session.list”) every 5 seconds, and crossbar add new session when something connects and it’s stay there forever. so what exacly auto_ping do?

W dniu środa, 19 października 2016 14:06:05 UTC+2 użytkownik Michał Lipiński napisał:

···

Hi,

I’m new to crossbar, and not sure exacly what I’m doing, but…

I’ve created object that store my users (name, id, session_id) and want to add session_id to user when he connect’s and remove it when he leave / disconnect for any reason .

so i created procedure that I call when user login, also I add

def onLeave(self, details) and def onDisconnect(self) but even if I close my app window that is connected those methods are never called ;(

I also added to my config:

“options”: {

“auto_ping_interval”: 1000,

“auto_ping_timeout”: 2000,

“auto_ping_size”: 4

}

but this is not helping.

what is the proper way to trace my connected clients and know when they disconnect?

0 Likes

#3

Hi!

The auto ping is there to provide minimal periodic traffic on idle connections. This prevents intermediaries from timing out and severing the connection.

The onLeave handler is called when the connection of the WAMP component itself is closed or lost, similar to the onOpen handler for the connection establishment.

To track connections, use the session meta-events - see http://crossbar.io/docs/Session-Metaevents-and-Procedures/. Using these you can track sessions entering and leaving/recognized disconnects as they happen. The session list will usually only be called when you first connect a monitoring component to get the number of connections at that time.

Regards,

Alex

0 Likes

#4

hi, thank You for Your response,
I did as You sugested, on_join working fine and returning:

Got event: {u’authprovider’: u’static’, u’authid’: u’5AGJ-6N5T-5FE9-VQ4E-CH3T-6V47’, u’authrole’: u’anonymous’, u’authmethod’: u’anonymous’, u’session’: 2096478250624450L, u’transport’: {u’cbtid’: None, u’protocol’: ‘wamp.2.json’, u’http_headers_received’: {u’upgrade’: u’websocket’, u’sec-websocket-version’: u’13’, u’sec-websocket-protocol’: u’wamp.2.json,wamp.2.msgpack’, u’host’: u’192.168.1.200:8080’, u’sec-websocket-key’: u’TwcztccSO84hnM+Lj6U53g==’, u’connection’: u’Upgrade’, u’sec-websocket-origin’: u’http://192.168.1.200:8080’}, u’peer’: u’tcp4:192.168.1.141:40887’, u’http_headers_sent’: {}, u’type’: ‘websocket’}}

but on_leave never fire. I turn off wifi on client and waiting…and waiting and nothing happened ;/

W dniu środa, 19 października 2016 18:31:05 UTC+2 użytkownik Alexander Gödde napisał:

···

Hi!

The auto ping is there to provide minimal periodic traffic on idle connections. This prevents intermediaries from timing out and severing the connection.

The onLeave handler is called when the connection of the WAMP component itself is closed or lost, similar to the onOpen handler for the connection establishment.

To track connections, use the session meta-events - see http://crossbar.io/docs/Session-Metaevents-and-Procedures/. Using these you can track sessions entering and leaving/recognized disconnects as they happen. The session list will usually only be called when you first connect a monitoring component to get the number of connections at that time.

Regards,

Alex

0 Likes

#5

ok, I’ve tested it more, and when I close my client (android app) on_leave fired , but when I turn of wifi event on_leave never fires ;/

W dniu czwartek, 20 października 2016 10:47:51 UTC+2 użytkownik Michał Lipiński napisał:

···

hi, thank You for Your response,
I did as You sugested, on_join working fine and returning:

Got event: {u’authprovider’: u’static’, u’authid’: u’5AGJ-6N5T-5FE9-VQ4E-CH3T-6V47’, u’authrole’: u’anonymous’, u’authmethod’: u’anonymous’, u’session’: 2096478250624450L, u’transport’: {u’cbtid’: None, u’protocol’: ‘wamp.2.json’, u’http_headers_received’: {u’upgrade’: u’websocket’, u’sec-websocket-version’: u’13’, u’sec-websocket-protocol’: u’wamp.2.json,wamp.2.msgpack’, u’host’: u’192.168.1.200:8080’, u’sec-websocket-key’: u’TwcztccSO84hnM+Lj6U53g==’, u’connection’: u’Upgrade’, u’sec-websocket-origin’: u’http://192.168.1.200:8080’}, u’peer’: u’tcp4:192.168.1.141:40887’, u’http_headers_sent’: {}, u’type’: ‘websocket’}}

but on_leave never fire. I turn off wifi on client and waiting…and waiting and nothing happened ;/

W dniu środa, 19 października 2016 18:31:05 UTC+2 użytkownik Alexander Gödde napisał:

Hi!

The auto ping is there to provide minimal periodic traffic on idle connections. This prevents intermediaries from timing out and severing the connection.

The onLeave handler is called when the connection of the WAMP component itself is closed or lost, similar to the onOpen handler for the connection establishment.

To track connections, use the session meta-events - see http://crossbar.io/docs/Session-Metaevents-and-Procedures/. Using these you can track sessions entering and leaving/recognized disconnects as they happen. The session list will usually only be called when you first connect a monitoring component to get the number of connections at that time.

Regards,

Alex

0 Likes

#6

doesn’t crossbar have any sort of mechanism that chceck health of session and close them if there was no resoponse for defined period of time?
everething works fine if you close connection as You should, but what if You lost connection o just pull the plug in client?

W dniu czwartek, 20 października 2016 10:56:24 UTC+2 użytkownik Michał Lipiński napisał:

···

ok, I’ve tested it more, and when I close my client (android app) on_leave fired , but when I turn of wifi event on_leave never fires ;/

W dniu czwartek, 20 października 2016 10:47:51 UTC+2 użytkownik Michał Lipiński napisał:

hi, thank You for Your response,
I did as You sugested, on_join working fine and returning:

Got event: {u’authprovider’: u’static’, u’authid’: u’5AGJ-6N5T-5FE9-VQ4E-CH3T-6V47’, u’authrole’: u’anonymous’, u’authmethod’: u’anonymous’, u’session’: 2096478250624450L, u’transport’: {u’cbtid’: None, u’protocol’: ‘wamp.2.json’, u’http_headers_received’: {u’upgrade’: u’websocket’, u’sec-websocket-version’: u’13’, u’sec-websocket-protocol’: u’wamp.2.json,wamp.2.msgpack’, u’host’: u’192.168.1.200:8080’, u’sec-websocket-key’: u’TwcztccSO84hnM+Lj6U53g==’, u’connection’: u’Upgrade’, u’sec-websocket-origin’: u’http://192.168.1.200:8080’}, u’peer’: u’tcp4:192.168.1.141:40887’, u’http_headers_sent’: {}, u’type’: ‘websocket’}}

but on_leave never fire. I turn off wifi on client and waiting…and waiting and nothing happened ;/

W dniu środa, 19 października 2016 18:31:05 UTC+2 użytkownik Alexander Gödde napisał:

Hi!

The auto ping is there to provide minimal periodic traffic on idle connections. This prevents intermediaries from timing out and severing the connection.

The onLeave handler is called when the connection of the WAMP component itself is closed or lost, similar to the onOpen handler for the connection establishment.

To track connections, use the session meta-events - see http://crossbar.io/docs/Session-Metaevents-and-Procedures/. Using these you can track sessions entering and leaving/recognized disconnects as they happen. The session list will usually only be called when you first connect a monitoring component to get the number of connections at that time.

Regards,

Alex

0 Likes

#7

Do you have the auto-ping set for your connections? (see http://crossbar.io/docs/WebSocket-Options/) With this on Crossbar should detect severed connections once the next ping fails. Otherwise, with no traffic, it isn’t possible to detect an unclean disconnect.

···

Am Montag, 24. Oktober 2016 10:36:45 UTC+2 schrieb Michał Lipiński:

doesn’t crossbar have any sort of mechanism that chceck health of session and close them if there was no resoponse for defined period of time?
everething works fine if you close connection as You should, but what if You lost connection o just pull the plug in client?

W dniu czwartek, 20 października 2016 10:56:24 UTC+2 użytkownik Michał Lipiński napisał:

ok, I’ve tested it more, and when I close my client (android app) on_leave fired , but when I turn of wifi event on_leave never fires ;/

W dniu czwartek, 20 października 2016 10:47:51 UTC+2 użytkownik Michał Lipiński napisał:

hi, thank You for Your response,
I did as You sugested, on_join working fine and returning:

Got event: {u’authprovider’: u’static’, u’authid’: u’5AGJ-6N5T-5FE9-VQ4E-CH3T-6V47’, u’authrole’: u’anonymous’, u’authmethod’: u’anonymous’, u’session’: 2096478250624450L, u’transport’: {u’cbtid’: None, u’protocol’: ‘wamp.2.json’, u’http_headers_received’: {u’upgrade’: u’websocket’, u’sec-websocket-version’: u’13’, u’sec-websocket-protocol’: u’wamp.2.json,wamp.2.msgpack’, u’host’: u’192.168.1.200:8080’, u’sec-websocket-key’: u’TwcztccSO84hnM+Lj6U53g==’, u’connection’: u’Upgrade’, u’sec-websocket-origin’: u’http://192.168.1.200:8080’}, u’peer’: u’tcp4:192.168.1.141:40887’, u’http_headers_sent’: {}, u’type’: ‘websocket’}}

but on_leave never fire. I turn off wifi on client and waiting…and waiting and nothing happened ;/

W dniu środa, 19 października 2016 18:31:05 UTC+2 użytkownik Alexander Gödde napisał:

Hi!

The auto ping is there to provide minimal periodic traffic on idle connections. This prevents intermediaries from timing out and severing the connection.

The onLeave handler is called when the connection of the WAMP component itself is closed or lost, similar to the onOpen handler for the connection establishment.

To track connections, use the session meta-events - see http://crossbar.io/docs/Session-Metaevents-and-Procedures/. Using these you can track sessions entering and leaving/recognized disconnects as they happen. The session list will usually only be called when you first connect a monitoring component to get the number of connections at that time.

Regards,

Alex

0 Likes

#8

Hi,

there are 2 perspectives involved here:

a) Crossbar.io (quickly) detecting a lost client
b) a client (quickly) detecting loss of connection to Crossbar.io

For a), activate the auto-pingpong facilities in Crossbar.io.
For b), you need to activate similar feature in the client library (AutobahnPython support that)

···

When using the latest Crossbar.io release (16.1), it’ll log at info level when it detects a lost connection - which should happen when you turn off Wifi on your client.

However, for the client to detect the loss of connectivity (onLeave/onDisconnect), you need b).

Cheers,
/Tobias

PS: All this isn’t really specific to Crossbar.io / WAMP, or WebSocket, but this is how TCP works on the Internet. Without sending something (and expecting a return), a peer can’t differentiate (quickly) between a very slow connection and a lost connection.

Am Montag, 24. Oktober 2016 10:36:45 UTC+2 schrieb Michał Lipiński:

doesn’t crossbar have any sort of mechanism that chceck health of session and close them if there was no resoponse for defined period of time?
everething works fine if you close connection as You should, but what if You lost connection o just pull the plug in client?

W dniu czwartek, 20 października 2016 10:56:24 UTC+2 użytkownik Michał Lipiński napisał:

ok, I’ve tested it more, and when I close my client (android app) on_leave fired , but when I turn of wifi event on_leave never fires ;/

W dniu czwartek, 20 października 2016 10:47:51 UTC+2 użytkownik Michał Lipiński napisał:

hi, thank You for Your response,
I did as You sugested, on_join working fine and returning:

Got event: {u’authprovider’: u’static’, u’authid’: u’5AGJ-6N5T-5FE9-VQ4E-CH3T-6V47’, u’authrole’: u’anonymous’, u’authmethod’: u’anonymous’, u’session’: 2096478250624450L, u’transport’: {u’cbtid’: None, u’protocol’: ‘wamp.2.json’, u’http_headers_received’: {u’upgrade’: u’websocket’, u’sec-websocket-version’: u’13’, u’sec-websocket-protocol’: u’wamp.2.json,wamp.2.msgpack’, u’host’: u’192.168.1.200:8080’, u’sec-websocket-key’: u’TwcztccSO84hnM+Lj6U53g==’, u’connection’: u’Upgrade’, u’sec-websocket-origin’: u’http://192.168.1.200:8080’}, u’peer’: u’tcp4:192.168.1.141:40887’, u’http_headers_sent’: {}, u’type’: ‘websocket’}}

but on_leave never fire. I turn off wifi on client and waiting…and waiting and nothing happened ;/

W dniu środa, 19 października 2016 18:31:05 UTC+2 użytkownik Alexander Gödde napisał:

Hi!

The auto ping is there to provide minimal periodic traffic on idle connections. This prevents intermediaries from timing out and severing the connection.

The onLeave handler is called when the connection of the WAMP component itself is closed or lost, similar to the onOpen handler for the connection establishment.

To track connections, use the session meta-events - see http://crossbar.io/docs/Session-Metaevents-and-Procedures/. Using these you can track sessions entering and leaving/recognized disconnects as they happen. The session list will usually only be called when you first connect a monitoring component to get the number of connections at that time.

Regards,

Alex

0 Likes