🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

How to find a free TCP port for testing PubSub+ with Docker

[Deleted User]
[Deleted User] Posts: 0
edited July 2019 in Tips and Tricks #1

To run a network server like Solace PubSub+, you must configure it to use ports that are not currently in use. However, ports 80 and 8080 are often used by other applications. This means that you need to find a free TCP port in order to test PubSub+ using Docker. Before you can find out which port is free, you have to find out what ports are already in use. The good news is there are tools that can help you identify them. I’ve listed some of them below.

Windows

Netstat

Command: netstat -a -n -p tcp | findstr LISTENING

Note: Netstat produces so many results that you need to filter them with findstr.

  • netstat

    • -a

      • Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.
    • -n

      • To see port numbers instead of port names like "http" or "epmap"
    • -p (protocol)

      • Shows only the ports that are using this protocol, in this example, tcp
    • For more info:

  • |

    • That’s a pipe symbol, not a capital i or a lowercase L.
    • This symbol “pipes” output from the previous command (netstat) to the next command (findstr)
  • findstr

    • findstr is a filter tool. It selects the lines with “LISTENING” in them and ignores other lines.
    • For more info:

TcpView by Sysinternals

This is a GUI tool for looking at TCP information on Windows.

  • Download it from Sysinternals/Microsoft
  • Read Microsoft Docs
  • To see port numbers instead of port names like "http" or "epmap", click on the “A” in the toolbar at the top left of the window.

Mac

Lsof

Command: lsof -i -P

  • Do not combine the two parameters, like “-iP”, to avoid misinterpretation by lsof.
  • Use sudo to include all the ports owned by system processes
  • For more details, run man lsof

Linux

ss

Command: ss -ltn

  • -l

    • listening ports only
  • -t

    • TCP ports only
  • -n

    • See port numbers, instead of port names like "http" or "epmap"
    • For more details, run man ss