I wrote a Windows Service that monitors a specific mailbox in an on-premises Exchange Server 2016. I used .Net Framework 4.7.2 and the EWS Managed API 2.2.0.
In production, this service will be running on a client's server running Windows Server 2019. Before I could deploy this service to my client's on-prem server, they asked me which (ephemeral) ports they needed to open for my service to use. I used TCPView to see which ports my service is using locally on my development machine and noticed that the ports always change when I restart the service and also while the service is running because EWS Managed API uses a new TCP connection every time it sends an HTTP request.
I am wondering if there is a way to specify a port or several ports for my service to use when making internet calls. Any help is greatly appreciated.