Archived

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

About Bidirectional connections

Hello,

Using Ice and searching the manual, I realized that -by default- TCP connections are not bidirectional.
As written in the manual, we can use Glacier2 and bidirectional mode in some cases.

But, why Ice does not use the bidirectional mode by default? Does that bring any benefits? (eg performance, features, etc...) that the full-duplex mode does not provide ?

I am curious to know the reasons.

Comments

  • xdm
    xdm La Coruña, Spain
    You can use Bidirectional connections without using Glacier2, see Bidirectional Connections - Ice 3.4 - ZeroC

    All TCP/SSL connections have the ability to be used as bidirectional connections. There is a demo in demo/Ice/bidir

    Best Regards,
    Jose
  • Yes, indeed, I saw that in the documentation.

    However, maybe I was not clear. My question was, is there any reason for Ice not to use bidirectional connection by default?

    For example, I make a server with an ObjectAdapter with fixed endpoint (let's say "tcp -h 1.2.3.4 -p 1337").
    On another side I make a client that uses a "stringified" (sorry for spelling) proxy (that is so "MyObject: tcp -h 1.2.3.4 -p 1337). That's all.
    In that configuration, and without any configuration tricks, I can observer that between my server and my client there are 2 TCP connections, one from the client to the server (with a dynamic port on the client side and the 1337 on the server side, that's okay) and another one from the server to the client (with another dynamic port different of the last one). Why?

    Why the default behavior does not use the native bidirectional ability of TCP? Why there are 2 connections where I need only one?

    Note: I can observe the same behaviour with UDP. Even if UDP does not support sessions, the processes could be using the same connection (I mean the same ports that are used from the client to the server)

    Edit: In my case, I needed Glacier2 because I was connected to an IceStorm instance that does not support bidirectional connections.
  • marc
    marc Florida
    The short answer is that the object and proxy model would break down on many different levels. It has been tried before, for a similar middleware platform, where it never worked properly. We didn't want to repeat the same mistakes with Ice, that's why we introduced a completely new proxy type, the Fixed Proxy for bidirectional connections.

    The long answer would really require us to write a paper about this, and is out of the scope of a simple answer here in this forum, I'm afraid :-)
  • That's the type of answer I was seeking. Thank you.
    I'd be very interested in read such a paper, hope you will make one, one day. ;-)
  • bernard
    bernard Jupiter, FL
    Daniel,

    Ice does not open a separate connection to send responses to requests: it uses the connection established by the client.
    Dany2901 wrote: »
    For example, I make a server with an ObjectAdapter with fixed endpoint (let's say "tcp -h 1.2.3.4 -p 1337").
    On another side I make a client that uses a "stringified" (sorry for spelling) proxy (that is so "MyObject: tcp -h 1.2.3.4 -p 1337). That's all.
    In that configuration, and without any configuration tricks, I can observer that between my server and my client there are 2 TCP connections, one from the client to the server (with a dynamic port on the client side and the 1337 on the server side, that's okay) and another one from the server to the client (with another dynamic port different of the last one). Why?

    In this case, there is only one connection, from the client to the server.

    A connection would be established from your server to your client only if your client has its own object adapter - typically hosting "callback" objects. And you could use a "bi-dir connection" to avoid this second connection.

    Here, I am not sure why you are seeing a connection from your server to your client. What does Ice.Trace.Network=2 show?

    Best regards,
    Bernard
  • Bernard,

    It seems, after some additional tests, that you are... right!
    I do not understand how I get to have 2 connections, but now with the same test code I can see only one connection... I obviously made a mistake somewhere (however I don't know where :confused: )

    Finally, to be sure that I am clear on this point, can I use "bi-dir connection" with an IceStorm instance? (ie. using the connection made with the TopicManager)
    And is there any possibility (I think there aren't) to be connected on an IceStorm instance on only one port ? (TopicManager and Publisher on the same port)

    Thanks for your time,
    Daniel
  • bernard
    bernard Jupiter, FL
    Hi Daniel,

    Connections are established between Ice clients and Ice object adapters - not Ice servers. And IceStorm has several object adapters:
    - service.Node (used for replication)
    - service.Publish
    - service.TopicManager

    As a result, you cannot establish a single connection from a client to both the Publish and TopicManager object adapter of your IceStorm server. These object adapters must also listen on separate ports.

    "bi-dir" is not a property of a connection, but more a pattern on how you can use a connection (with fixed proxies...). And you cannot tell IceStorm to use or create "fixed proxies" associated with an incoming connection.

    If your "client" (e.g. a subscriber) is behind a firewall, the solution is to use Glacier2. In this case, the connection client to Glacier2 is "bi-dir" (Glacier2 reuses this connection to send requests to Ice objects hosted by your client). The connection between Glacier2 and IceStorm would not be bi-dir: if your client hosts Ice objects (e.g. IceStorm subscribers), IceStorm would open a separate connection to your Glacier2 router to send requests to these subscribers through Glacier2.

    I hope this is all clear now!

    Best regards,
    Bernard