Github CI test are falling with open TCP port (TCPListener, .net) [closed]

1 day ago 1
ARTICLE AD BOX

GitHub CI tests are failing with a "Permission denied" message while trying to open a TCP port within a TCPListener class; the log can be found here.

GitHub CI config is located here, but I turn tests run off. Locally tests works almost fine (sometimes one of them could fail).

GitHub project where could be found all source code is here

In test code I was trying:

to use either 0.0.0.0 or 127.0.0.1 as a server address

to use dynamic port in TCPListener by passing 0 to constructor `

Listener = new TcpListener(IPAddress.Parse(channelCfg.IpAddress), channelCfg.Port)`

But in tests I am trying to use a random port from the range 17000 - 25000 .

Code that reproduce behavior (take from source code)

public async Task TestTCPPortOpen() { Random rand = new Random(DateTimeOffset.Now.Millisecond); int serverPort = rand.Next(17000, 25000); Listener = new TcpListener(IPAddress.Loopback, serverPort) // Port binding throws an exception }

My questions are:

Why I can't open TCP port in tests

Is it possible to do what I want to test: run one or multiple TCP listener and connect from 50 to 50000 clients and make some interactions.

What should be configured properly, what i missed in my CI config or maybe somewhere else.

Read Entire Article