Simple WS implementation questions

#1

Hi,

     I have few questions, try to find the documents or helps didn't find much material , I guess this is the best place to get my questions answered :). 

    I am writing a server using autobahn (not using pub-sub). 
  • In a subclass of In WebSocketServerProtocol, self.peer, self.peerstr and request.peer returns IPv4Address(TCP, ‘127.0.0.1’, 56299), in this ‘56299’ is a client id (if I am not wrong).
  • So is there a way (API) to get the client unique id (except to get a substr of this)?
  • This number seems unique so far, but will it be unique on multiple server with multiple autobahn instance? I guess no but still confirming?
  • is this number any how related to client end code (JS or any other client)? In short, can client modify this or get this number any how?
  • Is this okie to use this number as client id in our code or we should create our own unique id per client?
  • Some of android default browser does not support websocket and flash. So the only option left is long polling. Does autobahn provide the support of long-polling out of the box or we need to write the complete code? Or there is a any other solution for that.
  • Is there an api support for timer instance per client, like to do something per client periodically? For example send every client a msg after 10 mins of it’s joining.

So far I loved this technology :).

Thanks,

James

0 Likes

#2

Hi,

          I have few questions, try to find the documents or helps
didn't find much material , I guess this is the best place to get my
questions answered :).

         I am writing a server using autobahn (not using pub-sub).

  * In a subclass of In WebSocketServerProtocol, self.peer, self.peerstr

Please don't use self.peer or other instance variables directly (they change and should be considered implementation details) .. see below

    and request.peer returns IPv4Address(TCP, '127.0.0.1', *56299*), in
    this '56299' is a client id (if I am not wrong).

http://autobahn.ws/static/reference/python/websocketserver.html#autobahn.websocket.protocol.ConnectionRequest

"peer (str) � Descriptor of the connecting client (eg IP address/port in case of TCP transports)."

The number you see in that _string_ (56299) is the client's IP port for the connection to the server (the so-called ephemeral port).

Clients will reuse that port. The _pair_ of source IP/port is unique: but _only_ for a given point in time.

      o So is there a way (API) to get the client unique id (except to
        get a substr of this)?

No. Eg Autobahn now can run WebSocket not only over TCP but also over Unix pipes or domain sockets (which don't even have IP addresses).

Above string should be considered a debugging aid (or for logging purposes). WAMP assigns unique _session_ IDs to clients (unrelated to IP/port). Each WAMP session (from same or differnt clients) will get unique WAMP session ID (which is just a random thing).

      o This number seems unique so far, but will it be unique on
        multiple server with multiple autobahn instance? I guess no but
        still confirming?

Like above: client IP/port pairs are unique for a given moment in time.

      o is this number any how related to client end code (JS or any
        other client)? In short, can client modify this or get this
        number any how?

What client? A C program can certainly open a TCP to your server and chose a (free) ephemeral port. Browser JavaScript not (as far as I know).

      o Is this okie to use this number as client id in our code or we
        should create our own unique id per client?

Better use your onw "unique" thing. And: What is unique? Unique and persistent over time? If so, you probably better use a cookie or JS client storage. Don't use IP/port numbers.
Using cookies/client storage, you can store something random which can be unique for that browser and all it's connections to your server. 2 browsers on same user machine will have different cookies though.

  * Some of android default browser does not support websocket and
    flash. So the only option left is long polling. Does autobahn
    provide the support of long-polling out of the box or we need to
    write the complete code? Or there is a any other solution for that.

The upcoming WAMPv2 will have a HTTP long-poll transport (besides WebSocket) .. it'll be here (not yet finished):

https://github.com/tavendo/AutobahnPython/blob/master/autobahn/autobahn/wamp2/http.py

  * Is there an api support for timer instance per client, like to do
    something per client periodically? For example send every client a
    msg after 10 mins of it's joining.

def onOpen(self):
    def dosomething():
       self.sendMessage("hey, still handing around?")
    reactor.callLater(60*10, dosomething)

So far I loved this technology :).

Great! Feel free to ask more;)

/Tobias

···

Am 11.01.2014 00:17, schrieb Chuck James:

Thanks,
James

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#3

I realize that there are different protocols that carry web sockets. In my implementation I am using tcp/ip so that a web browser can connect. I have a need to record the apparent ip address associated with that protocol type for auditing purposes. How can I get my hands on the protocol’s endpoint information (properly)? In this case it is tcp/ip, but, there are also the other cases (datagram et al).

-g

···

On Friday, January 10, 2014 5:49:21 PM UTC-6, Tobias Oberstein wrote:

Am 11.01.2014 00:17, schrieb Chuck James:

Hi,

      I have few questions, try to find the documents or helps

didn’t find much material , I guess this is the best place to get my

questions answered :).

     I am writing a server using autobahn (not using pub-sub).
  • In a subclass of In WebSocketServerProtocol, self.peer, self.peerstr

Please don’t use self.peer or other instance variables directly (they
change and should be considered implementation details) … see below

0 Likes

#4

You can use `peer` attribute of
http://autobahn.ws/static/reference/python/websocketserver.html#autobahn.websocket.protocol.ConnectionRequest

···

Am 08.02.2014 21:24, schrieb Greg Fausak:

> I realize that there are different protocols that carry web sockets. In
my implementation I am using tcp/ip so that a web browser can connect.
  I have a need to record the apparent ip address associated with that
protocol type for auditing purposes. How can I get my hands on the
protocol's endpoint information (properly)? In this case it is tcp/ip,
but, there are also the other cases (datagram et al).

0 Likes