[ 
https://issues.apache.org/jira/browse/DISPATCH-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15147705#comment-15147705
 ] 

Ganesh Murthy commented on DISPATCH-214:
----------------------------------------

Proton's connection object pn_connection_t has a field called pn_string_t 
*hostname;

Proton's Python binding sets the connection.hostname field to host:port. This 
happens in the Connector class in reactor.py as shown below.

{code:title=reactor.py|borderStyle=solid}
def _connect(self, connection):
        url = self.address.next()
        # IoHandler uses the hostname to determine where to try to connect to
        connection.hostname = "%s:%s" % (url.host, url.port)
        logging.info("connecting to %s..." % connection.hostname)

        transport = Transport()
        if self.sasl_enabled:
            sasl = transport.sasl()
            sasl.allow_insecure_mechs = self.allow_insecure_mechs
            if url.username:
                connection.user = url.username
            elif self.user:
                connection.user = self.user
            if url.password:
                connection.password = url.password
            elif self.password:
                connection.password = self.password
            if self.allowed_mechs:
                sasl.allowed_mechs(self.allowed_mechs)
        transport.bind(connection)
        if self.heartbeat:
            transport.idle_timeout = self.heartbeat
        if url.scheme == 'amqps' and self.ssl_domain:
            self.ssl = SSL(transport, self.ssl_domain)
            self.ssl.peer_hostname = url.host
{code}

In Proton's connection.c, the port is extracted from the hostname and a socket 
is opened as shown below - 
{code:title=connection.c|borderStyle=solid}
void pni_handle_bound(pn_reactor_t *reactor, pn_event_t *event) {
  assert(reactor);
  assert(event);

  pn_connection_t *conn = pn_event_connection(event);
  const char *hostname = pn_connection_get_hostname(conn);
  if (!hostname) {
      return;
  }
  pn_string_t *str = pn_string(hostname);
  char *host = pn_string_buffer(str);
  const char *port = "5672";
  char *colon = strrchr(host, ':');
  if (colon) {
    port = colon + 1;
    colon[0] = '\0';
  }
  pn_socket_t sock = pn_connect(pn_reactor_io(reactor), host, port);
{code}

It seems like the pn_connection_t needs to have a port field in it. This is not 
a trivial change. I wonder if I should close this bug and create a JIRA in the 
proton project.

> Qd tools include port number in AMQP Open hostname
> --------------------------------------------------
>
>                 Key: DISPATCH-214
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-214
>             Project: Qpid Dispatch
>          Issue Type: Bug
>          Components: Management Agent
>    Affects Versions: 0.5
>            Reporter: Chuck Rolke
>
> A command like:
> {noformat}
> qdmanage -b amqp://u1:password@photoserver:21000 --type policyStats query
> {noformat}
> sends the port number in the hostname field of the AMQP Open:
> {noformat}
> Mon Feb  8 11:37:46 2016 SERVER (trace) [2]:0 <- @open(16) 
> [container-id="34e49947-b4df-4a01-9570-0a74e9e57b5b", 
> hostname="photoserver:21000", channel-max=32767] 
> (/home/chug/git/qpid-dispatch/src/server.c:75)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to