Tough to assist when you're communicating with a local service. First step would be some sort of check to see the service you're pinging is running, is on the right port, and responding to whatever basic request you can give it.
I'm not sure if this is what you mean