How to disconnect client using Autobahn websocket server

#1

just call

def sendClose(self, code = None, reason = None)

available on WebSocketServerProtocol and WebSocketClientProtocol

will start closing handshake .. exactly as browser.

Cheers,
Tobias

···

Am 08.09.2012 23:20, schrieb Rizwan:

Hi, i am using the example of autobahn websocket server in python.
now as a client in javascript, one can disconnect the socket using
socket.close(), however if one wants to disconnect connected client from
the server how can this be done??

0 Likes

#2

It’s hard to use autobahnPython for me , I don’t konw how to use the pamas code and reason, I need a example. Sorry~~~ but thanks a lot!

在 2012年9月10日星期一UTC+8上午1时40分50秒,Tobias Oberstein写道:

···

Am 08.09.2012 23:20, schrieb Rizwan:

Hi, i am using the example of autobahn websocket server in python.

now as a client in javascript, one can disconnect the socket using

socket.close(), however if one wants to disconnect connected client from

the server how can this be done??

just call

def sendClose(self, code = None, reason = None)

available on WebSocketServerProtocol and WebSocketClientProtocol

will start closing handshake … exactly as browser.

Cheers,

Tobias

0 Likes

#3

Hi Tobias,

Can you elaborate a bit or maybe provide a simple example. I have a broadcast server with multiple possible clients and am looking to target specific connects to close based on a response from the client. Really, I’m trying to do a simple password(pin) authentication and close connections that do not have the proper password. Any help will be appreciated!

Kevin

···

On Sunday, September 9, 2012 10:40:50 AM UTC-7, Tobias Oberstein wrote:

Am 08.09.2012 23:20, schrieb Rizwan:

Hi, i am using the example of autobahn websocket server in python.

now as a client in javascript, one can disconnect the socket using

socket.close(), however if one wants to disconnect connected client from

the server how can this be done??

just call

def sendClose(self, code = None, reason = None)

available on WebSocketServerProtocol and WebSocketClientProtocol

will start closing handshake … exactly as browser.

Cheers,

Tobias

0 Likes

#4

Kevin,

not sure what you exactly a trying to do:

“response from client”: the broadcast server does not receive responses, but just dispatches anything it receives to all currently connected clients.

Usually, a “response” is something a peer sends upon a “request” … that would be a “Request/Response” pattern. You might have a look at the WAMP examples that come with AutobahnPython. Those provide “Remote Procedure Calls” (= Request/Response) and PubSub. They also show how to do authentication. And WAMP also allows you to target specific clients, since WAMP assign unique session IDs to clients (which is needed, at least when referring a session from a different session).

Of course you could reinvent parts of WAMP on your own … however, I’d not recommend that, but instead first look if WAMP already provides what you need. If so, that’ll much quicker for you, and you also profit from the work done on WAMP now and in the future.

/Tobias

···

Am Donnerstag, 24. Oktober 2013 01:35:10 UTC+2 schrieb Kevin Helton:

Hi Tobias,

Can you elaborate a bit or maybe provide a simple example. I have a broadcast server with multiple possible clients and am looking to target specific connects to close based on a response from the client. Really, I’m trying to do a simple password(pin) authentication and close connections that do not have the proper password. Any help will be appreciated!

Kevin

On Sunday, September 9, 2012 10:40:50 AM UTC-7, Tobias Oberstein wrote:

Am 08.09.2012 23:20, schrieb Rizwan:

Hi, i am using the example of autobahn websocket server in python.

now as a client in javascript, one can disconnect the socket using

socket.close(), however if one wants to disconnect connected client from

the server how can this be done??

just call

def sendClose(self, code = None, reason = None)

available on WebSocketServerProtocol and WebSocketClientProtocol

will start closing handshake … exactly as browser.

Cheers,

Tobias

0 Likes

#5

Thanks Tobias, I’ll take a look and give it a go!

···

On Friday, October 25, 2013 2:26:29 AM UTC-7, Tobias Oberstein wrote:

Kevin,

not sure what you exactly a trying to do:

“response from client”: the broadcast server does not receive responses, but just dispatches anything it receives to all currently connected clients.

Usually, a “response” is something a peer sends upon a “request” … that would be a “Request/Response” pattern. You might have a look at the WAMP examples that come with AutobahnPython. Those provide “Remote Procedure Calls” (= Request/Response) and PubSub. They also show how to do authentication. And WAMP also allows you to target specific clients, since WAMP assign unique session IDs to clients (which is needed, at least when referring a session from a different session).

Of course you could reinvent parts of WAMP on your own … however, I’d not recommend that, but instead first look if WAMP already provides what you need. If so, that’ll much quicker for you, and you also profit from the work done on WAMP now and in the future.

/Tobias

Am Donnerstag, 24. Oktober 2013 01:35:10 UTC+2 schrieb Kevin Helton:

Hi Tobias,

Can you elaborate a bit or maybe provide a simple example. I have a broadcast server with multiple possible clients and am looking to target specific connects to close based on a response from the client. Really, I’m trying to do a simple password(pin) authentication and close connections that do not have the proper password. Any help will be appreciated!

Kevin

On Sunday, September 9, 2012 10:40:50 AM UTC-7, Tobias Oberstein wrote:

Am 08.09.2012 23:20, schrieb Rizwan:

Hi, i am using the example of autobahn websocket server in python.

now as a client in javascript, one can disconnect the socket using

socket.close(), however if one wants to disconnect connected client from

the server how can this be done??

just call

def sendClose(self, code = None, reason = None)

available on WebSocketServerProtocol and WebSocketClientProtocol

will start closing handshake … exactly as browser.

Cheers,

Tobias

0 Likes

#6

There is also a way to unceremoniously drop a connection: it will look something like this:

class MyWebSocket(WebSocketServerProtocol):

def unceremoniouslyKillClient(self):

self.transport.loseConnection()

This doesn’t shut down the websocket protocol, it just loses the tcp conneciton.

···

On Saturday, October 26, 2013 9:19:29 PM UTC-7, Kevin Helton wrote:

Thanks Tobias, I’ll take a look and give it a go!

On Friday, October 25, 2013 2:26:29 AM UTC-7, Tobias Oberstein wrote:

Kevin,

not sure what you exactly a trying to do:

“response from client”: the broadcast server does not receive responses, but just dispatches anything it receives to all currently connected clients.

Usually, a “response” is something a peer sends upon a “request” … that would be a “Request/Response” pattern. You might have a look at the WAMP examples that come with AutobahnPython. Those provide “Remote Procedure Calls” (= Request/Response) and PubSub. They also show how to do authentication. And WAMP also allows you to target specific clients, since WAMP assign unique session IDs to clients (which is needed, at least when referring a session from a different session).

Of course you could reinvent parts of WAMP on your own … however, I’d not recommend that, but instead first look if WAMP already provides what you need. If so, that’ll much quicker for you, and you also profit from the work done on WAMP now and in the future.

/Tobias

Am Donnerstag, 24. Oktober 2013 01:35:10 UTC+2 schrieb Kevin Helton:

Hi Tobias,

Can you elaborate a bit or maybe provide a simple example. I have a broadcast server with multiple possible clients and am looking to target specific connects to close based on a response from the client. Really, I’m trying to do a simple password(pin) authentication and close connections that do not have the proper password. Any help will be appreciated!

Kevin

On Sunday, September 9, 2012 10:40:50 AM UTC-7, Tobias Oberstein wrote:

Am 08.09.2012 23:20, schrieb Rizwan:

Hi, i am using the example of autobahn websocket server in python.

now as a client in javascript, one can disconnect the socket using

socket.close(), however if one wants to disconnect connected client from

the server how can this be done??

just call

def sendClose(self, code = None, reason = None)

available on WebSocketServerProtocol and WebSocketClientProtocol

will start closing handshake … exactly as browser.

Cheers,

Tobias

0 Likes