Uploaded image for project: 'Solution Center'
  1. Solution Center
  2. SOL-307

Check connectibility of EXASolution to external network services

    XMLWordPrintable

    Details

    • Type: How To
    • Status: Published
    • Affects Version/s: EXASOL 6.0.0, Exasol 6.1.0, EXASolution 5.0.0
    • Fix Version/s: None
    • Component/s: EXASolution
    • Labels:
      None
    • Solution:
      Hide

      When connecting to external network services from a database (e.g. via IMPORT/EXPORT commands or scripts), a user may not know if such a connection is at least possible. This may be due to

      1. firewalls that block or abort connections,
      2. missing network routes,
      3. temporary network issues,
      4. missing DNS entries, etc.

      Here are two examples to easily check network connectivity of an EXASolution database to a host with IP address 192.168.2.1 and TCP port 80 with the help of scripting. As a return code, these scripts either return "OK" in case of success or an exception.

      Lua

      CREATE OR REPLACE LUA SCALAR SCRIPT
      lua_connect(hostname varchar(4096), port varchar(4096))
      RETURNS varchar(4096)
      AS
      socket = require("socket")
      function run(ctx)
          sock = assert(socket.tcp())
          assert(sock:connect(ctx.hostname, ctx.port))
          sock:close()
          return 'OK'
      end
      /
      
      SELECT lua_connect('192.168.2.1', '80') res FROM dual;
      

      Python

      CREATE OR REPLACE PYTHON SCALAR SCRIPT
      python_connect(hostname varchar(4096), port varchar(4096))
      RETURNS varchar(4096)
      AS
      import socket
      
      def run(ctx):
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          sock.connect((ctx.hostname, int(ctx.port)))
          sock.close()
          return 'OK'
      /
      
      SELECT python_connect('192.168.2.1', '80') res FROM dual;
      
      Show
      When connecting to external network services from a database (e.g. via IMPORT/EXPORT commands or scripts), a user may not know if such a connection is at least possible. This may be due to firewalls that block or abort connections, missing network routes, temporary network issues, missing DNS entries, etc. Here are two examples to easily check network connectivity of an EXASolution database to a host with IP address 192.168.2.1 and TCP port 80 with the help of scripting. As a return code, these scripts either return "OK" in case of success or an exception. Lua CREATE OR REPLACE LUA SCALAR SCRIPT lua_connect(hostname varchar (4096), port varchar (4096)) RETURNS varchar (4096) AS socket = require ( "socket" ) function run(ctx) sock = assert(socket.tcp()) assert(sock: connect (ctx.hostname, ctx.port)) sock: close () return 'OK' end / SELECT lua_connect( '192.168.2.1' , '80' ) res FROM dual ; Python CREATE OR REPLACE PYTHON SCALAR SCRIPT python_connect(hostname varchar (4096), port varchar (4096)) RETURNS varchar (4096) AS import socket def run(ctx): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock. connect ((ctx.hostname, int (ctx.port))) sock. close () return 'OK' / SELECT python_connect( '192.168.2.1' , '80' ) res FROM dual ;
    • Category 1:
      Scripting
    • Category 2:
      Cluster Administration

      Attachments

        Issue Links

          Activity

            People

            • Assignee:
              CaptainEXA Captain EXASOL
              Reporter:
              CaptainEXA Captain EXASOL
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: