Most Antivirus and spamwares come with firewall for implementing security on our machines.
However, most of our applications that uses SMTP or any API that looks out for remote resource over the network fails because the firewall blocks our applications to interact with the remote systems / resources.
One classic example is using Google Talk API to send recieve messages.
Steps to replicate the scenario.
1. Download the code. (click here). Extract it to any folder. Set "smackx-3.1.0.jar" and "smack-3.1.0.jar" in the current classpath.
G:\shuttingdownweblogicserverremotely>set classpath=G:\shuttingdownweblogicserverremotely\smackx-3.1.0.jar;G:\shuttingdownweblogicserverremotely\smack-3.1.0.jar;%classpath%
2. Install any firewall and enable it. I have Symantec Firewall.
3. Execute the "MessageListener" class
java otn.adf.googletalk.MessageListener
My message listener class fails to execute giving this error trace.
G:\shuttingdownweblogicserverremotely>java otn.adf.googletalk.MessageListener
Exception in thread "main" XMPPError connecting to talk.google.com:5222.: remote
-server-error(502) XMPPError connecting to talk.google.com:5222.
-- caused by: java.net.ConnectException: Connection refused: connect
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:900)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at otn.adf.googletalk.MessageListener.
at otn.adf.googletalk.MessageListener.main(MessageListener.java:50)
Nested Exception:
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.jivesoftware.smack.proxy.DirectSocketFactory.createSocket(DirectSocketFactory.java:28)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:888)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at otn.adf.googletalk.MessageListener.
at otn.adf.googletalk.MessageListener.main(MessageListener.java:50)
Let's check if my firewall is ON and ACTIVE.
Unfortunately YES :)
Let's turn OFF the firewall and test the program.
WOW!!! it Works :)
Now that it works try to turn ON the firewall and see if it still is able to connect and communicate with the remote resource.
Well it does. Hope you liked the article.
No comments:
Post a Comment