这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ZIMkaRU
Copy link
Member

@ZIMkaRU ZIMkaRU commented Mar 7, 2023

This PR improves the lookup of the free ports for the backend side of the app and fixes the issue: #171


The issue is the following:

  • When Windows 10 have all possible security features enabled, it is using Virtualization-based Security, this one is running on top Hyper-V
  • Docker and Hyper-V reserve some ranges of ports, eg:
PS C:\WINDOWS\system32> netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
      1080        1179
      1263        1362
      1363        1462
      1702        1801
      1882        1981
      1982        2081
      2182        2281
      2380        2479
      2480        2579
      2580        2679
      2680        2779
      2780        2879
      2880        2979
      2980        3079
      3081        3180
      3262        3361
      5357        5357
      5437        5536
      5537        5636
      5737        5836
      5837        5936
     24249       24348
     24349       24448
     24549       24648
     24649       24748
     50000       50059     *

* - Administered port exclusions.

PS C:\WINDOWS\system32> netsh interface ipv4 show excludedportrange protocol=udp

Protocol udp Port Exclusion Ranges

Start Port    End Port
----------    --------
     50000       50059     *
     50266       50365
     50366       50465
     50566       50665
     50666       50765
     54431       54530
     54531       54630
     54731       54830
     54831       54930
     55031       55130
     55131       55230
     55331       55430
     55529       55628
     55929       56028
     56029       56128
     56129       56228
     56229       56328
     56329       56428
     56429       56528
     56529       56628
     56629       56728
     57097       57196
     57197       57296
     57297       57396
     57397       57496

* - Administered port exclusions.
  • Previous the port lookup implementation works is the following: if the default port is inaccessible, the next one (prevPort + 1) is taken and checked, and makes 100 attempts until finding a free port or throwing an error
  • This can't resolve the issue with big reserved port ranges

The current implementation defines the following ports:

  • default ports:
{
  grape1DhtPort: 20002,
  grape1ApiPort: 40001,
  grape2DhtPort: 20001,
  grape2ApiPort: 30001,
  workerApiPort: 3501,
  workerWsPort: 10001,
  expressApiPort: 34343
}
  • port ranges for looking up:
[
  { from: 3500, to: 5000 },
  { from: 6000, to: 24000 },
  { from: 25000, to: 49990 }
]

And uses get-port module which provides better behavior for ports lookup. It will use any element in the preferred ports array if available, otherwise fall back to a random port


Basic changes:


Depends on this PR:

Waiting for the corresponding frontend implementation of using the free port lookup flow of the express API on the backend side

Copy link
Contributor

@ezewer ezewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment as to remove chai, rest looks good!

@@ -0,0 +1,100 @@
'use strict'

const { assert } = require('chai')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer avoiding chai and doing tests in a different way.
Example assert.ok(_.isObject(res)
)

package.json Outdated
"devDependencies": {
"@mapbox/node-pre-gyp": "1.0.6",
"app-builder-bin": "4.1.0",
"chai": "4.3.7",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer avoiding chai

Copy link
Contributor

@ezewer ezewer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@ezewer ezewer merged commit f3b8ad1 into bitfinexcom:beta Mar 8, 2023
This was referenced Mar 15, 2023
This was referenced Apr 12, 2023
@ZIMkaRU ZIMkaRU deleted the feature/improve-port-lookup branch March 13, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants