为什么Neo4j Java进程以随机范围大块打开端口?

时间:2019-03-27 21:43:21

标签: java tcp neo4j port

看来Neo4j 3.4.1(Windows)使用的端口数量超过了其文档说明的数量(请参阅https://neo4j.com/docs/operations-manual/current/configuration/ports/)。除了用于连接的标准端口外,它还开放了大块端口。我们已经看到大约20到250个端口在5000到35000年代的任何相对连续的块中打开。这些都是通过同一Java进程(作为控制台应用程序运行的Neo4j服务器)或Commons Daemon Server Runner进程(Windows服务)打开的所有端口。在通过TCP连接建立的每两个端口之间,端口似乎是配对的。

我无法弄清楚这些端口是什么,或者找不到任何提及这些端口使用的文档。似乎端口的数量与数据库的大小有关。

我也查看了Neo4j 2.3.2,它似乎也使用了一些神秘的端口,尽管在这种情况下,块大小只有六个。

由于我们使用的是APOC库,因此我将其从plugins目录中删除,然后重新启动服务器以查看是否有影响。这似乎不是问题。

了解该进程为何使用这些端口当然很高兴;但是,根本的问题是它的行为像一个坏公民,在往往存在性能更好的应用程序的地方占用了很大的端口。有没有办法控制它们将在什么范围内打开?似乎,如果这些端口模块是必需的,则应在临时端口范围内打开它们,而不会使其他应用程序崩溃。

编辑:根据@InverseFalcon的建议,以下是使用Neo4j 3.5.3的Java进程占用的端口的示例:

    H:\>netstat -a -o | find /I "17048"
      TCP    0.0.0.0:7473           mysvr:0              LISTENING       17048
      TCP    0.0.0.0:7474           mysvr:0              LISTENING       17048
      TCP    0.0.0.0:7687           mysvr:0              LISTENING       17048
      TCP    127.0.0.1:36418        mysvr:36419          ESTABLISHED     17048
      TCP    127.0.0.1:36419        mysvr:36418          ESTABLISHED     17048
      TCP    127.0.0.1:36420        mysvr:36421          ESTABLISHED     17048
      TCP    127.0.0.1:36421        mysvr:36420          ESTABLISHED     17048
      TCP    127.0.0.1:36422        mysvr:36423          ESTABLISHED     17048
      TCP    127.0.0.1:36423        mysvr:36422          ESTABLISHED     17048
      TCP    127.0.0.1:36424        mysvr:36425          ESTABLISHED     17048
      TCP    127.0.0.1:36425        mysvr:36424          ESTABLISHED     17048
      TCP    127.0.0.1:36426        mysvr:36427          ESTABLISHED     17048
      TCP    127.0.0.1:36427        mysvr:36426          ESTABLISHED     17048
      TCP    127.0.0.1:36428        mysvr:36429          ESTABLISHED     17048
      TCP    127.0.0.1:36429        mysvr:36428          ESTABLISHED     17048
      TCP    127.0.0.1:36430        mysvr:36431          ESTABLISHED     17048
      TCP    127.0.0.1:36431        mysvr:36430          ESTABLISHED     17048
      TCP    127.0.0.1:36432        mysvr:36433          ESTABLISHED     17048
      TCP    127.0.0.1:36433        mysvr:36432          ESTABLISHED     17048
      TCP    127.0.0.1:36434        mysvr:36435          ESTABLISHED     17048
      TCP    127.0.0.1:36435        mysvr:36434          ESTABLISHED     17048
      TCP    127.0.0.1:36436        mysvr:36437          ESTABLISHED     17048
      TCP    127.0.0.1:36437        mysvr:36436          ESTABLISHED     17048
      TCP    127.0.0.1:36438        mysvr:36439          ESTABLISHED     17048
      TCP    127.0.0.1:36439        mysvr:36438          ESTABLISHED     17048
      TCP    127.0.0.1:36440        mysvr:36441          ESTABLISHED     17048
      TCP    127.0.0.1:36441        mysvr:36440          ESTABLISHED     17048
      TCP    127.0.0.1:36442        mysvr:36443          ESTABLISHED     17048
      TCP    127.0.0.1:36443        mysvr:36442          ESTABLISHED     17048
      TCP    127.0.0.1:36444        mysvr:36445          ESTABLISHED     17048
      TCP    127.0.0.1:36445        mysvr:36444          ESTABLISHED     17048
      TCP    127.0.0.1:36446        mysvr:36447          ESTABLISHED     17048
      TCP    127.0.0.1:36447        mysvr:36446          ESTABLISHED     17048
      TCP    127.0.0.1:36448        mysvr:36449          ESTABLISHED     17048
      TCP    127.0.0.1:36449        mysvr:36448          ESTABLISHED     17048
      TCP    127.0.0.1:36450        mysvr:36451          ESTABLISHED     17048
      TCP    127.0.0.1:36451        mysvr:36450          ESTABLISHED     17048
      TCP    127.0.0.1:36452        mysvr:36453          ESTABLISHED     17048
      TCP    127.0.0.1:36453        mysvr:36452          ESTABLISHED     17048
      TCP    127.0.0.1:36454        mysvr:36455          ESTABLISHED     17048
      TCP    127.0.0.1:36455        mysvr:36454          ESTABLISHED     17048
      TCP    127.0.0.1:36456        mysvr:36457          ESTABLISHED     17048
      TCP    127.0.0.1:36457        mysvr:36456          ESTABLISHED     17048
      TCP    127.0.0.1:36458        mysvr:36459          ESTABLISHED     17048
      TCP    127.0.0.1:36459        mysvr:36458          ESTABLISHED     17048
      TCP    127.0.0.1:36460        mysvr:36461          ESTABLISHED     17048
      TCP    127.0.0.1:36461        mysvr:36460          ESTABLISHED     17048
      TCP    127.0.0.1:36462        mysvr:36463          ESTABLISHED     17048
      TCP    127.0.0.1:36463        mysvr:36462          ESTABLISHED     17048
      TCP    127.0.0.1:36464        mysvr:36465          ESTABLISHED     17048
      TCP    127.0.0.1:36465        mysvr:36464          ESTABLISHED     17048
      TCP    127.0.0.1:36466        mysvr:36467          ESTABLISHED     17048
      TCP    127.0.0.1:36467        mysvr:36466          ESTABLISHED     17048
      TCP    127.0.0.1:36468        mysvr:36469          ESTABLISHED     17048
      TCP    127.0.0.1:36469        mysvr:36468          ESTABLISHED     17048
      TCP    127.0.0.1:36470        mysvr:36471          ESTABLISHED     17048
      TCP    127.0.0.1:36471        mysvr:36470          ESTABLISHED     17048
      TCP    127.0.0.1:36472        mysvr:36473          ESTABLISHED     17048
      TCP    127.0.0.1:36473        mysvr:36472          ESTABLISHED     17048
      TCP    127.0.0.1:36474        mysvr:36475          ESTABLISHED     17048
      TCP    127.0.0.1:36475        mysvr:36474          ESTABLISHED     17048
      TCP    127.0.0.1:36476        mysvr:36477          ESTABLISHED     17048
      TCP    127.0.0.1:36477        mysvr:36476          ESTABLISHED     17048
      TCP    127.0.0.1:36478        mysvr:36479          ESTABLISHED     17048
      TCP    127.0.0.1:36479        mysvr:36478          ESTABLISHED     17048
      TCP    [::]:7473              mysvr:0              LISTENING       17048
      TCP    [::]:7474              mysvr:0              LISTENING       17048
      TCP    [::]:7687              mysvr:0              LISTENING       17048
      TCP    [::1]:7687             mysvr:36483          ESTABLISHED     17048
      TCP    [::1]:7687             mysvr:36484          ESTABLISHED     17048
      TCP    [::1]:7687             mysvr:36485          ESTABLISHED     17048
      TCP    [::1]:7687             mysvr:36486          ESTABLISHED     17048
      TCP    [::1]:7687             mysvr:36487          ESTABLISHED     17048

如果关闭螺栓,则滑块变小:

H:\>netstat -a -o | find /I "20520"
  TCP    0.0.0.0:7473           mysvr:0              LISTENING       20520
  TCP    0.0.0.0:7474           mysvr:0              LISTENING       20520
  TCP    127.0.0.1:36902        mysvr:36903          ESTABLISHED     20520
  TCP    127.0.0.1:36903        mysvr:36902          ESTABLISHED     20520
  TCP    127.0.0.1:36904        mysvr:36905          ESTABLISHED     20520
  TCP    127.0.0.1:36905        mysvr:36904          ESTABLISHED     20520
  TCP    127.0.0.1:36906        mysvr:36907          ESTABLISHED     20520
  TCP    127.0.0.1:36907        mysvr:36906          ESTABLISHED     20520
  TCP    127.0.0.1:36908        mysvr:36909          ESTABLISHED     20520
  TCP    127.0.0.1:36909        mysvr:36908          ESTABLISHED     20520
  TCP    127.0.0.1:36910        mysvr:36911          ESTABLISHED     20520
  TCP    127.0.0.1:36911        mysvr:36910          ESTABLISHED     20520
  TCP    127.0.0.1:36912        mysvr:36913          ESTABLISHED     20520
  TCP    127.0.0.1:36913        mysvr:36912          ESTABLISHED     20520
  TCP    [::]:7473              mysvr:0              LISTENING       20520
  TCP    [::]:7474              mysvr:0              LISTENING       20520

如果关闭了https,则它会更小:

    H:\>netstat -a -o | find /I "20556"
      TCP    0.0.0.0:7474           mysvr:0              LISTENING       20556
      TCP    127.0.0.1:36962        mysvr:36963          ESTABLISHED     20556
      TCP    127.0.0.1:36963        mysvr:36962          ESTABLISHED     20556
      TCP    127.0.0.1:36964        mysvr:36965          ESTABLISHED     20556
      TCP    127.0.0.1:36965        mysvr:36964          ESTABLISHED     20556
      TCP    127.0.0.1:36966        mysvr:36967          ESTABLISHED     20556
      TCP    127.0.0.1:36967        mysvr:36966          ESTABLISHED     20556
      TCP    [::]:7474              mysvr:0              LISTENING       20556

1 个答案:

答案 0 :(得分:0)

因此,这可能是Windows不支持套接字对的结果,因此将管道实现为回送连接。尽管它起源于Windows XP,但似乎在Windows系统中仍在继续。看起来好像所使用的端口号已被更改,或者至少不受限制。

这是在此older Java bug的结尾处捕获的:

  

Windows不支持套接字对,因此Pipe在该平台上作为回送连接实现。该连接的“客户端”端未明确绑定,因此它在1024-5000范围内分配了一个临时端口。

java.io.OutputStream的用法将以这种方式实现为回送。

我将做一些后续工作,看看是否可以获得更多信息。