Failed to parse host name "2a00:8a00:4000:20c::87:0fa6": invalid port)

Trying to setup kong to connect to a cassandra cluster( IPv6 single node ).
I have setup cassandra via IPv6 address.
node02 is DB node
[root@eden0142node02 ~]# lsof -i “:8942”
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 30452 cassandra_kong 171u IPv6 34519627 0t0 TCP *:8942 (LISTEN)

Kong is setup in node01

proxy_listen = [::1]:8903 # Address and port on which Kong will accept
# HTTP requests.
# This is the public-facing entrypoint of
# Kong, to which your consumers will make
# requests.

Note: See http://nginx.org/en/docs/http/ngx_http_core_module.html#listen for

a description of the accepted formats for this and other *_listen values.

proxy_listen_ssl = [2a00:8a00:4000:20c::87:0fa5]:9500 # Address and port on which Kong will accept
# HTTPS requests if ssl is enabled.

admin_listen = [::1]:8902 # Address and port on which Kong will expose
# an entrypoint to the Admin API.
# This API lets you configure and manage Kong,
# and should be kept private and secured.

admin_listen_ssl = [2a00:8a00:4000:20c::87:0fa5]:8901 # Address and port on which Kong will accept
# HTTPS requests to the admin API, if
# admin_ssl is enabled.

cassandra_contact_points = 2a00:8a00:4000:20c::87:0fa6 # A comma-separated list of contact
# points to your cluster.

cassandra_port = 8942 # The port on which your nodes are listening
# on. All your nodes and contact points must
# listen on the same port.

Upon giving cassandra_contact_points as IPv6 address, kong migrations itself failed, with
[root@eden0142node01 ~]# /usr/local/bin/kong migrations up --vv
2020/05/12 09:38:00 [verbose] Kong: 0.11.2
2020/05/12 09:38:00 [debug] ngx_lua: 10008
2020/05/12 09:38:00 [debug] nginx: 1011002
2020/05/12 09:38:00 [debug] Lua: LuaJIT 2.1.0-beta2
2020/05/12 09:38:00 [verbose] reading config file at /etc/kong/kong.conf
2020/05/12 09:38:00 [debug] admin_access_log = “/var/log/kong/admin_access.log”
2020/05/12 09:38:00 [debug] admin_error_log = “/var/log/kong/error.log”
2020/05/12 09:38:00 [debug] admin_http2 = false
2020/05/12 09:38:00 [debug] admin_listen = “[::1]:8902”
2020/05/12 09:38:00 [debug] admin_listen_ssl = “[2a00:8a00:4000:20c::87:0fa5]:8901”
2020/05/12 09:38:00 [debug] admin_ssl = true
2020/05/12 09:38:00 [debug] admin_ssl_cert = “/opt/kong/kong.crt”
2020/05/12 09:38:00 [debug] admin_ssl_cert_key = “/opt/kong/kong.key”
2020/05/12 09:38:00 [debug] anonymous_reports = false
2020/05/12 09:38:00 [debug] cassandra_consistency = “ONE”
2020/05/12 09:38:00 [debug] cassandra_contact_points = {“2a00:8a00:4000:20c::87:0fa6”}
2020/05/12 09:38:00 [debug] cassandra_data_centers = {“dc1:2”,“dc2:3”}
2020/05/12 09:38:00 [debug] cassandra_keyspace = “kong”
2020/05/12 09:38:00 [debug] cassandra_lb_policy = “RoundRobin”
2020/05/12 09:38:00 [debug] cassandra_password = “******”
2020/05/12 09:38:00 [debug] cassandra_port = 8942
2020/05/12 09:38:00 [debug] cassandra_repl_factor = 1
2020/05/12 09:38:00 [debug] cassandra_repl_strategy = “SimpleStrategy”
2020/05/12 09:38:00 [debug] cassandra_schema_consensus_timeout = 10000
2020/05/12 09:38:00 [debug] cassandra_ssl = true
2020/05/12 09:38:00 [debug] cassandra_ssl_verify = false
2020/05/12 09:38:00 [debug] cassandra_timeout = 5000
2020/05/12 09:38:00 [debug] cassandra_username = “kong”
2020/05/12 09:38:00 [debug] client_body_buffer_size = “8k”
2020/05/12 09:38:00 [debug] client_max_body_size = “0”
2020/05/12 09:38:00 [debug] client_ssl = false
2020/05/12 09:38:00 [debug] custom_plugins = {}
2020/05/12 09:38:00 [debug] database = “cassandra”
2020/05/12 09:38:00 [debug] db_cache_ttl = 3600
2020/05/12 09:38:00 [debug] db_update_frequency = 5
2020/05/12 09:38:00 [debug] db_update_propagation = 1
2020/05/12 09:38:00 [debug] dns_error_ttl = 1
2020/05/12 09:38:00 [debug] dns_hostsfile = “/etc/hosts”
2020/05/12 09:38:00 [debug] dns_no_sync = false
2020/05/12 09:38:00 [debug] dns_not_found_ttl = 30
2020/05/12 09:38:00 [debug] dns_order = {“LAST”,“SRV”,“A”,“CNAME”}
2020/05/12 09:38:00 [debug] dns_resolver = {}
2020/05/12 09:38:00 [debug] dns_stale_ttl = 4
2020/05/12 09:38:00 [debug] error_default_type = “text/plain”
2020/05/12 09:38:00 [debug] http2 = false
2020/05/12 09:38:00 [debug] latency_tokens = false
2020/05/12 09:38:00 [debug] log_level = “notice”
2020/05/12 09:38:00 [debug] lua_package_cpath = “”
2020/05/12 09:38:00 [debug] lua_package_path = “./?.lua;./?/init.lua;”
2020/05/12 09:38:00 [debug] lua_socket_pool_size = 30
2020/05/12 09:38:00 [debug] lua_ssl_trusted_certificate = “/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem”
2020/05/12 09:38:00 [debug] lua_ssl_verify_depth = 1
2020/05/12 09:38:00 [debug] mem_cache_size = “128m”
2020/05/12 09:38:00 [debug] nginx_daemon = “on”
2020/05/12 09:38:00 [debug] nginx_optimizations = true
2020/05/12 09:38:00 [debug] nginx_user = “kong kong”
2020/05/12 09:38:00 [debug] nginx_worker_processes = “auto”
2020/05/12 09:38:00 [debug] pg_database = “kong”
2020/05/12 09:38:00 [debug] pg_host = “127.0.0.1”
2020/05/12 09:38:00 [debug] pg_port = 5432
2020/05/12 09:38:00 [debug] pg_ssl = false
2020/05/12 09:38:00 [debug] pg_ssl_verify = false
2020/05/12 09:38:00 [debug] pg_user = “kong”
2020/05/12 09:38:00 [debug] prefix = “/opt/kong”
2020/05/12 09:38:00 [debug] proxy_access_log = “off”
2020/05/12 09:38:00 [debug] proxy_error_log = “/var/log/kong/error.log”
2020/05/12 09:38:00 [debug] proxy_listen = “[::1]:8903”
2020/05/12 09:38:00 [debug] proxy_listen_ssl = “[2a00:8a00:4000:20c::87:0fa5]:9500”
2020/05/12 09:38:00 [debug] real_ip_header = “X-Real-IP”
2020/05/12 09:38:00 [debug] real_ip_recursive = “off”
2020/05/12 09:38:00 [debug] server_tokens = false
2020/05/12 09:38:00 [debug] ssl = true
2020/05/12 09:38:00 [debug] ssl_cert = “/opt/kong/kong.crt”
2020/05/12 09:38:00 [debug] ssl_cert_key = “/opt/kong/kong.key”
2020/05/12 09:38:00 [debug] ssl_cipher_suite = “modern”
2020/05/12 09:38:00 [debug] ssl_ciphers = “ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256”
2020/05/12 09:38:00 [debug] trusted_ips = {}
2020/05/12 09:38:00 [debug] upstream_keepalive = 60
2020/05/12 09:38:00 [verbose] prefix in use: /opt/kong
2020/05/12 09:38:00 [verbose] running datastore migrations
Error:
/usr/local/share/lua/5.1/kong/cmd/migrations.lua:34: [cassandra error] could not find coordinator: all hosts tried for query failed. 2a00:8a00:4000:20c::87:0fa6: host seems unhealthy, considering it down (Address family for hostname not supported)

stack traceback:
[C]: in function ‘assert’
/usr/local/share/lua/5.1/kong/cmd/migrations.lua:34: in function ‘cmd_exec’
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
[C]: in function ‘xpcall’
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
/usr/local/bin/kong:7: in function ‘file_gen’
init_worker_by_lua:39: in function <init_worker_by_lua:37>
[C]: in function ‘xpcall’
init_worker_by_lua:46: in function <init_worker_by_lua:44>
Changing casandra_contact_points to hostname - eden0142node02.netact.nsn-rdnet.net, migrations worked.
But in /var/log/kong/error.log, following errors are seen( Kong service was also active )
2020/05/12 09:40:51 [error] 8578#0: *37837 [lua] cluster_events.lua:369: [cluster_events] failed to poll: failed to retrieve events from DB: all hosts tried for query failed. eden0142node02.netact.nsn-rdnet.net: host seems unhealthy, considering it down (failed to parse host name “2a00:8a00:4000:20c::87:0fa6”: invalid port), context: ngx.timer
2020/05/12 09:40:56 [error] 8578#0: *37909 [lua] cluster_events.lua:369: [cluster_events] failed to poll: failed to retrieve events from DB: all hosts tried for query failed. eden0142node02.netact.nsn-rdnet.net: host still considered down, context: ngx.timer

Any help is appreciated

BTW I am using kong- 0.11.2


Dont know if its related

Further Inputs
cassandra@cqlsh:system> select cluster_name, listen_address, broadcast_address, rpc_address from local;

cluster_name | listen_address | broadcast_address | rpc_address
----------------±---------------------------±---------------------------±------------
Cassandra_Kong | 2a00:8a00:4000:20c::87:fa6 | 2a00:8a00:4000:20c::87:fa6 | ::

This was released more than 2 years ago and is not supported. I’d recommend you to upgrade.There are a lot of features that have shipped between then and now.

Will try to upgrade to any latest version. Meanwhile i tried to find the rootcause for this issue of failed to parse hostname with invalid port.
In lua-cassandra-master’s socket.lua,

function _M.tcp(...)
  local phase = get_phase()
  if not forced_luasocket_phases[phase]
     and COSOCKET_PHASES[phase]
     or forbidden_luasocket_phases[phase] then
    return ngx_socket.tcp(...)
  end

This method is called from init.lua. The problem is with this ngx_socket.tcp()
It doesnt seem to take Ipv6 host addresses.
I replaced it with

function _M.tcp(...)
  local phase = get_phase()
  
  if not forced_luasocket_phases[phase]
     and COSOCKET_PHASES[phase]
     or forbidden_luasocket_phases[phase] then
    return setmetatable({
    sock = socket.tcp6(...)
  }, proxy_mt)
  end

Only after using socket.tcp6 was i able to get rid of this problem.
Will this be solved by upgrading to latest kong along with its dependencies.

Thanks in advance


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ