Archived

This forum has been archived. Please start a new discussion on GitHub.

IceJS not respecting connectionId

I have slice file something like this :
module Test1 {

   interface Session {
      void setMsg (string msg);
   };

   exception AccessDenied {
      string username;
   };

   interface Authenticator {
      Session* login (string username, string password)
         throws AccessDenied;
   };
};

Now I am using python for server implementation, and in the servant implementation of Session and Authenticator, I did this in two of the methods :
class SessionImpl (Test1.Session) :
   def setMsg (self, msg, current = None) :
      print ('Session:setMsg')
      print (current.con.toString ())

...

class AuthenticatorImpl (Test1.Authenticator) :
   def login (self, username, password, current = None) :
      print ('Authenticator:login')
      print (current.con.toString ())
      ...

Now I wrote two clients, one in python and one javascript. In both the clients, I put all proxies through .ice_connectionId () method.

In python client, I did this :
base = ic.stringToProxy ('....')
base = base.ice_connectionId ('cg1')
authenticator = Test1.AuthenticatorPrx.checkedCast (base)
...
session = authenticator.login (...)
session = session.ice_connectionId ('cg1')
session.setMsg ('hello')

Doing that generated this output on server, which is expected :
Authenticator:login
local address = 127.0.0.1:10000
remote address = 127.0.0.1:48522
Session:setMsg
local address = 127.0.0.1:10000
remote address = 127.0.0.1:48522

Notice, the port on remote address, its same. Now, in javascript client (which I accessed via browser), I did this :
var base = ic.stringToProxy ('...')
base = base.ice_connectionId ('cg1')
Test1.AuthenticatorPrx.checkedCast (base).then (function (authenticator) {
   authenticator.login (username, password).then (function (session) {
      session = session.ice_connectionId ('cg1')
      session.setMsg ('asdf')

...

Now, the output on server is :
Authenticator:login
local address = 127.0.0.1:10001
remote address = 127.0.0.1:52385
Session:setMsg
local address = 127.0.0.1:10001
remote address = 127.0.0.1:52386

Notice, the ports of remote address, they are DIFFERENT.

Furthuremore, asking to print connection id on console in javascript, both authenticator and session print 'cg1', but still making two connections. It can also be verified by turning on tracing on server, it shows separate connections being made.

Specifications of my system :
Operating System : Ubuntu 14.04 (64-bit)
GCC version : 4.8.2
Python version : 3.4.2
Ice version : 3.5.1
IceJS version : 0.1.0
Browser : Firefox 34.0

I have compiled Ice and IceJS myself. I made sure, via environment variables like LD_LIBRARY_PATH etc, that IceJS libraries are loaded first by the dynamic loader (otherwise there will be errors of undefined symbols). Please tell me if you need any more info about the bug or my sytem.

Or this might not be a bug but a limitation of javascript/websocket, I am not sure.

Comments

  • xdm
    xdm La Coruña, Spain
    This should work, can you enable network tracing in client and server setting
    Ice.Trace.Network=3
    
    and post the logs

    Can you also print the client proxies to see if they are different
    var base = ic.stringToProxy ('...')
    base = base.ice_connectionId ('cg1')
    Test1.AuthenticatorPrx.checkedCast (base).then (function (authenticator) {
    [B]   console.log(authenticator.toString())[/B]
       authenticator.login (username, password).then (function (session) {
          session = session.ice_connectionId ('cg1')
          [B]console.log(session.toString())[/B]
          session.setMsg ('asdf')
    

    If you attach a test case to reproduce the problem I will be happy to look at it.
  • Sure, I attach a simple case where the bug is reproduced.

    I have written a slice file, a python server, a python client, an html file with embedded javascript, and few supporting scripts to invoke them. I included a README to describe how to start server/client etc.

    On my machine, this is reproducing the bug successfuly
  • xdm
    xdm La Coruña, Spain
    This is a bug with JS the WS endpoint initializes the default value for the resource attribute to the empty string, and Python initializes it to "/" so when JavaScript looks for a connection doesn't found any because the endpoint attributes does not match.

    To workaround this you can set the resource attribute in JavaScript when you create the endpoint using -r endpoint option.
    var base = ic.stringToProxy ('Authenticator:ws -h localhost -p 10001 [B]-r /[/B]')
    

    Thanks for the bug report
  • Ohh I see.

    Tried that workaround, its no longer spawning new connections, thanks.