Results 1 to 4 of 4
  1. #1
    i007 is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default 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:

    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
    This is how the server properties file looks like:

    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
    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.

    Does anybody have a hint on this?
    I appreciate your help.

  2. #2
    Xyle's Avatar
    Xyle is offline Member
    Join Date
    Feb 2009
    Location
    Nevada
    Posts
    34
    Rep Power
    0

    Default

    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.

  3. #3
    i007 is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    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

  4. #4
    Xyle's Avatar
    Xyle is offline Member
    Join Date
    Feb 2009
    Location
    Nevada
    Posts
    34
    Rep Power
    0

    Default

    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

  1. Socket applet programming error?
    By Master Zero in forum Java Applets
    Replies: 6
    Last Post: 10-05-2011, 10:15 PM
  2. How to open a socket through proxy ?
    By arnab321 in forum New To Java
    Replies: 2
    Last Post: 03-04-2009, 09:39 PM
  3. log4j with Applet
    By sunjavaboy in forum Java Applets
    Replies: 0
    Last Post: 03-25-2008, 01:13 AM
  4. Replies: 1
    Last Post: 12-17-2007, 12:13 PM
  5. Replies: 4
    Last Post: 06-08-2007, 07:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •