In this article I am going to share familiar exception, but that killed my many hours, even days.
Senario: I want to call third party web service from application in openshift (PaaS from redhat) cloud instance.
I was stuck with below exception.
java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
As a debug practice I tried telnet the web service target host and port. This connected successfully.
So I am wondering what was going wrong!
Now let me find whether the third party web service reject the connection on particular url from openshift instance.
We can get the help of curl command line utility, but for authentication we have few header params, I agree we can pass header params too in curl, so we did curl command from openshift instance.
Surprisingly that too was success. We are able to post content to web service and working as expected. But still our core problem of calling web service from our application was failing and wondering what is going wrong!!
Same application connects third party web service and works fine from my local PC, why not in openshift instance? Even though telnet and curl command succeeded to connect third party web service from openshift.
Essential steps of debugging such as Reproducibility, Reduction, Deduction, Experimentation was over. So what next? Experience & Tenacity :-) Certainly programmer’s good friend Googling too.
Yes! it helped me to find the culprit, which is not my code but Commons HttpClient 3.x.
But it opens another nightmare since HttpClient 4.x replace totally HttpClient 3.x and not normal upgrade of version as we experience from other libraries from Apache. Still it is enjoyable let me cover it in next blog…