Connectivity Check from APIGEE SaaS to Target Servers

Previously we have a nodejs script to test the connectivity between Apigee SaaS and Target Servers. However, post recent upgrade - nodejs is not compatible with present Apigee SaaS version. We tried creating a Python script - also a separate java script instead of nodejs - but we are seeing the below problem.

- When we try the script locally - have no trouble connecting to any servers/websites - and throws errors for invalid hosts - as expected

- However, when we deploy this script as Proxy to test our target servers - we get success for all valid & invalid hosts.

Can some one guide if I am missing anything here?


#!/usr/bin/python import socket import time def isValidHost(domain): try: socket.gethostbyname(domain) return True except socket.gaierror: # this means could not resolve the host print("there was an error resolving the host") return False def isConnected(domain, port, retry): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(timeout) s.connect((domain, int(port))) s.shutdown(socket.SHUT_RDWR) print("connected") return True except BaseException: print(retry) print('Error occurred while establishing connection...') return False if isValidHost(domain): domain = "google.com" port = 443 retry = 2 delay = 5 timeout = 3 while (retry != 0): if isConnected(domain, port, retry): retry = 0 else: retry = retry - 1 else: print('Invalid host')
0 2 210
2 REPLIES 2

Apigee currently supports a pretty old version of Python. v2.5.2 if I am recalling correctly. Probably that's the reason your script does not work as expected.

Can you explain why you need to use the script to check connectivity? Apigee does this for you with the TargetServer entity. Have you explored that? Will it suffice? If not why not? What is the root problem you are trying to solve? (Why do you feel the need to build logic that explicitly checks the liveness of remote servers?)

HI Dino ,Thanks for you response .We have many backend serves which change frequently , we need to check the firewall connectivity for those hosts every time . I am trying to create an api call , which will take host name and port in the body and check if there is connectivity or not .For now i am hard coding the values . We can do this by creating a proxy and add adding the host as target and tracing it , but it a time consuming process for more number of proxy's .