Home Comments

About Bidirectional connections

Dany2901Dany2901 Member Daniel BerlemontOrganization: Egidium TechnologiesProject: Applicative modules communication over IP network
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

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    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
  • Dany2901Dany2901 Member Daniel BerlemontOrganization: Egidium TechnologiesProject: Applicative modules communication over IP network
    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.
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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 :-)
  • Dany2901Dany2901 Member Daniel BerlemontOrganization: Egidium TechnologiesProject: Applicative modules communication over IP network
    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. ;-)
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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
  • Dany2901Dany2901 Member Daniel BerlemontOrganization: Egidium TechnologiesProject: Applicative modules communication over IP network
    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
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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
Sign In or Register to comment.