• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1351
  • Last Modified:

JBoss socket connection problem

Hello there
I made a servlet that load on server startup and accept socket connections through an applet.
Problem is that this works fine in Tomcat but in Jboss this is not working. Applet shows Connection refused exception.
To my mind, This can happen for two reasons. First Jboss does not allow socket connection as i have done nothing in jBoss configuration for socket connections. Second servlet does not load on Jboss start up. For this I am using same web.xml which i use in tomcat.
Please guide.
0
tripat
Asked:
tripat
  • 2
1 Solution
 
visorxCommented:
Since you have moved from tomcat to Jboss I'll suggest to check the codebase url including port. Applet is allowed to communicate to the server from which it originated. If this doesn't help then a full stacktrace of the exception will help to solve this.
Cheers,
0
 
tripatAuthor Commented:
Hello visorx
I managed to make it work on jboss. now i am facing another problem and that is related to socket connection. Applet does connect with servlet on localhost but do not connect on servlet at server. it gives Connecion time out exception. Please see the stacktrace below. Even on locahost if use url https://localhost:port/webapp it works. but if i use url https://ipaddress:port/webapp it gives following exception.
Thanks for your reply and please guide me.
java.net.ConnectException: Connection timed out: 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.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at java.net.Socket.<init>(Unknown Source)
	at java.net.Socket.<init>(Unknown Source)
	at MonitorApplet.getDateUsingSocketText(MonitorApplet.java:225)
	at MonitorApplet.refresh(MonitorApplet.java:217)
	at MonitorApplet.run(MonitorApplet.java:183)
	at java.lang.Thread.run(Unknown Source)

Open in new window

0
 
visorxCommented:
Uh ho.. if you are using raw socket connection to connect to server in applet code then you are bound to run into problems. I'd recommend to use HTTP to connect to server rather than raw socket. So instead of using plain java.net.Socket, you can use, java.net.URL and java.net.URLConnection. This will help you in long run, as most (I can say 99%) Firewalls will allow HTTP but will block plain socket.
Now as to why localhost works but IP address fails, there can be one of the two reasons, first is that for localhost, you'll not need proxy, but if you used IP address then  your java code is not able to resolve the IP without proxy, second is Firewalls simply don't care for connection coming from and to localhost, as they make sure that host entry for localhost does loop back to same machine. (hosts file on windows box).
Anyways I'd strongly recommend to not use plain socket code in applet.
Hope this helps,
Cheers
0
 
ramazanyichCommented:
jboss starting from version4.2 is binding by default only to localhost.
If you want that jboss binds to all ip addresses n your machine start jboss like that:
on windows:
>run.bat -b 0.0.0.0
on unix:
>run.sh -b 0.0.0.0
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now