$Client_API_Service_protocol_and_host= 'http://WinAppServer.domain.local' # Http address of your Zylinc Windows Application Server, as seen from your LAN $Client_API_Service_port= '35046' # Client API Service port (CasPort), as seen from your LAN $Client_API_WebSocket_port= '35047' # Client API WebSocket port (PersistentConnectionWebSocketPort), as seen from your LAN $Gateway_protocol_and_host_LAN = 'https://WinAppServer.domain.local' # Https address of your Zylinc Windows Application server, as seen from your LAN (ClientAPIHost) $Gateway_port_LAN = '35063' # Gateway service port (ClientAPIHost / OcelotRoot / ClientAPIPort / ClientAPIWebSocketPort) $Gateway_protocol_and_host_Internet = 'https://InternetHost.companydomain.com' # Https address of your Zylinc Windows Application server, as seen from the smartphone on the Internet $Gateway_port_Internet = '35063' # Gateway service port, as seen from the smartphone on the Internet. Previously known as GateKeeper WAN port or Client Manager WAN port. If you upgrade from legacy Zylinc mobile app, use the old WAN port, for example: 35033 or 49022 or 8090 ######## function Test_CAS_port_by_web_request ($Protocol_and_host, $Portnumber) { try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # This line because: https://stackoverflow.com/questions/41897114 Write-Host "$((Invoke-WebRequest ${Protocol_and_host}:${Portnumber}/zylinc/api/v1.0/auth/identityServer).StatusDescription)" -ForegroundColor Green } catch { Write-Host "ERROR: $($error[0].Exception.Message)" -ForegroundColor Red } } function Test_CAS_WebSocket_by_web_request ($Protocol_and_host, $Portnumber) { try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # This line because: https://stackoverflow.com/questions/41897114 Invoke-WebRequest "${Protocol_and_host}:${Portnumber}/socket" } catch { if ($Error[0].Exception.Message -ilike '*400*bad*request*') { # We assume WebSocket is OK if we get the following response: (400) Bad Request. # Unfortunately this is as far as we can get usning a simple PowerShell script. # It's a bit dirty but at least we know that the WebSocket port is open and that a mapping for the /socket contextpath exists in the reverse proxy Write-Host "OK" -ForegroundColor Green } else { # We assume an error happened in all other cases Write-Host "ERROR: $($error[0].Exception.Message)" -ForegroundColor Red } } } write-host "Test 1 - Client API port no gateway: " -NoNewline ; Test_CAS_port_by_web_request $Client_API_Service_protocol_and_host $Client_API_Service_port write-host "Test 2 - Client API port through LAN gateway: " -NoNewline ; Test_CAS_port_by_web_request $Gateway_protocol_and_host_LAN $Gateway_port_LAN write-host "Test 3 - Client API port through Internet gateway: " -NoNewline ; Test_CAS_port_by_web_request $Gateway_protocol_and_host_Internet $Gateway_port_Internet write-host "Test 4 - Client API WebSocket port no gateway: " -NoNewline ; Test_CAS_WebSocket_by_web_request $Client_API_Service_protocol_and_host $Client_API_WebSocket_port write-host "Test 5 - Client API WebSocket port through LAN gateway: " -NoNewline ; Test_CAS_WebSocket_by_web_request $Gateway_protocol_and_host_LAN $Gateway_port_LAN write-host "Test 6 - Client API WebSocket port through Internet gateway: " -NoNewline ; Test_CAS_WebSocket_by_web_request $Gateway_protocol_and_host_Internet $Gateway_port_Internet