我正在尝试在我的java应用程序上访问Azure托管的SQL数据库。我使用nmap检查了端口1433,它显示它已关闭:
default
我编辑了/etc/pf.conf并重新启动了我的mac,但端口仍然关闭。这是我的pf.conf:
Starting Nmap 7.12 ( https://nmap.org ) at 2016-09-02 09:44 PHT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00014s latency).
Other addresses for localhost (not scanned): ::1
PORT STATE SERVICE
1433/tcp closed ms-sql-s
此外,我的防火墙已设置为关闭。
我的java应用程序抛出此错误:
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
pass in proto tcp from any to any port 1433
Java代码:
Error starting database: The TCP/IP connection to the host flowengine7.database.windows.net, port 1433 has failed. Error: "Connection timed out: no further information. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
答案 0 :(得分:1)
您忽略了Azure SQL 服务器级防火墙:
https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings/
您需要将Mac的公共IP地址列入其中,以便能够从本地连接。默认情况下,只有Azure服务可以在Azure SQL实例上达到1433 / TCP(允许在Azure SQL防火墙中允许访问Azure服务设置)。
如果您每次重启DSL / Cable / Fiber调制解调器时都获得新的公共IP地址,则需要定义一整套地址而不仅仅是一个地址(即 174.73.0.0 - 174.73。 255.255 与列出 174.73.16.180 )。希望你总能获得相同范围内的IP地址。