The strange whereabouts of http_proxy (and the solution in 11g of course)
Friday, August 31st, 2007It’s time to write something about 11g. It is the latest fashion to do so.
A question of a former co-worker and a blog of tanel poder triggered me to start writing something about using sqlplus on the commandline in linux and the http_proxy environment variable.
Little background on environment variable http_proxy: This environment variable lets you specify a proxy which gets used by (commandline) processes which are spawned from the shell in which it is set (and exported!). This enables you to use wget, curl, elinks, yum, apt-get etc. in environments which are not directly connected to the internet, but have internet access using a proxy.
Whilst working with version 9 (9.2.0.4) I encountered a strange phenomena: the http_proxy environment was set (I probably needed to download something), and sqlplus failed to work. Unsetting it resulted in expected behavior:
[oracle@centos44-ias101202 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.1.0.4.2 - Production on Fri Aug 31 09:27:48 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit
Disconnected
Now set http_proxy to some value:
[oracle@centos44-ias101202 ~]$ export http_proxy=whatever
[oracle@centos44-ias101202 ~]$ sqlplus "/as sysdba"
Error 46 initializing SQL*Plus
Internal error
And unset it:
[oracle@centos44-ias101202 ~]$ unset http_proxy
[oracle@centos44-ias101202 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.1.0.4.2 - Production on Fri Aug 31 09:27:48 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit
Disconnected
[oracle@centos44-ias101202 ~]$
Actually http_proxy fits its purpose exactly, only the error message (or the lack of it, actually) is confusing:
[oracle@centos44-ias101202 ~]$ export http_proxy=http://localhost
[oracle@centos44-ias101202 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.1.0.4.2 - Production on Fri Aug 31 09:27:48 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit
Disconnected
[oracle@centos44-ias101202 ~]$
This means sqlplus obeys the http_proxy environment variable (probably, I haven’t tested it; anyone?)
SQL*Plus versions and messages
9.2.0.6
Error 46 initializing SQL*Plus
Internal error
10.1.0.4.2 (database which is enclosed in application server 10.1.2.0.2)
Error 46 initializing SQL*Plus
Internal error
10.2.0.3
Error 46 initializing SQL*Plus
HTTP proxy setting has incorrect value
SP2-1502: The HTTP proxy server specified by http_proxy is not accessible
11.1.0.6
Error 46 initializing SQL*Plus
HTTP proxy setting has incorrect value
SP2-1502: The HTTP proxy server specified by http_proxy is not accessible
This means a more clear errormessage is introduced in version 10.2 instead of 11g (so no new 11g feature; sorry
)
Does this error message tells you what is happening?
Eh…no. According to the message, SQL*Plus has tested the accessibility of the host specified in the http_proxy environment variable, which could either mean it has tested if it could reach the host, or also could be interpreted as it has tested it is able to talk HTTP.
When looking at the system calls SQL*Plus made, it couldn’t have tested the host (no name lookup has been done either using DNS or /etc/hosts), and no network socket has been opened. This probably means SQL*Plus checked if the syntax of the http_proxy variable was correct.