Results 1 to 4 of 4
- 03-18-2009, 05:35 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Cannot open socket with Log4J from Applet
Dear all,
I'm new to this forum, so first of all, hello everybody. ;)
Well, I'm quite desperate with a problem with my applet: I want to keep track of the interactions of the users with my applications. To record such log files, I'm using Log4J. The idea is to open a socket from the applet (running on the client machine, of course) to my server. As I've seen in the Applet's policy, one can only stablish connections with the same server that hosts the applet.
This is the configuration file of the client:
This is how the server properties file looks like:Java Code:gui_logger.to_socket=false gui_logger.socket_host=XXX gui_logger.socket_port=4815 gui_logger.to_file=false gui_logger.file_pattern=%d{yyyy-MM-dd HH:mm:ss}\t%p\t%m%n gui_logger.file_name=gui.log gui_logger.file_date='.'yyyy-MM-dd gui_logger.to_console=false gui_logger.console_pattern=GUI: %d{yyyy-MM-dd HH:mm:ss}\t%p\t%m%n gui_logger.console_target=System.err
What is currently happening is that the socket works, if i run the applet from my Eclipse. However, it does not work when running the applet from the browser. This server is indeed behing a firewall, but the destination port is completely opened.Java Code:log4j.appender.gui=org.apache.log4j.DailyRollingFileAppender log4j.appender.gui.layout=org.apache.log4j.PatternLayout log4j.appender.gui.Append=true log4j.appender.gui.ImmediateFlush=true log4j.appender.gui.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}\t%p\t%m%n log4j.appender.gui.File=gui_daily.log log4j.appender.gui.DatePattern='.'yyyy-MM-dd
Does anybody have a hint on this?
I appreciate your help.
- 03-19-2009, 01:33 AM #2
Not 100% sure about this but...
All my coding is with applets and as far as testing them, I installed a home webserver using apache. When I test out an applet, I copy it to the webserver public access folder and run the applet. The reason for this is because all my applets get/recieve data from the server or are multiplayer games.
If your applet is trying to communicate, send, recieve data to or from the server within a browser, I believe you would have to set up a webserver.
I think it works in eclipse because its an emulated enviroment within eclipse.
I dont think your browser applet knows who its supposed to talk to because you dont have an actual webserver running.
- 03-19-2009, 09:45 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
I'm not really sure if I'm getting your idea. My server has an Apache server, which is the one that serves the Applet... Is that what you mean?
Thank you for your help
- 03-20-2009, 03:01 AM #4
Ahhh yes, so you are using a webserver and I assume from home. Have you looked at the Java console to see what, if any, error messages come up?
If your getting the security error, your not telling the applet the right instructions in the socket setup.
Try putting some System.out.println's in your code to see exactly where the code is failing, if it is failing at all. I personally like to put printlns in each method start and depending on how complex the method is, will put some inside if statements or after for loops, etc. That way if the code breaks, I look at the console to see what was the last method it printed or what was the last variable output in order to pin point exactly where the problem occurred.
Of course it could always be the way the server is setup. Are you able to view any html pages from the browser that your webserver is serving? Your typing localhost in the broswer right? That should pull up your index.html file in the htdocs folder of your apache directory unless you specified something different. Try putting a simple applet in your index file to make sure that works. Then refer to the java console if your serving pages work to see if any errors show up.
I know this is pretty long winded, but I'm mentally preparing for a key mashing session...
If your running a server side app to handle the client calls and requests, check the errors reported there also and let the forum know if you are seeing any error output.
Similar Threads
-
Socket applet programming error?
By Master Zero in forum Java AppletsReplies: 6Last Post: 10-05-2011, 09:15 PM -
How to open a socket through proxy ?
By arnab321 in forum New To JavaReplies: 2Last Post: 03-04-2009, 08:39 PM -
log4j with Applet
By sunjavaboy in forum Java AppletsReplies: 0Last Post: 03-25-2008, 12:13 AM -
Socket refused, but applet talking to native server
By Waccoon in forum NetworkingReplies: 1Last Post: 12-17-2007, 11:13 AM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks