Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Interesting Problem - Host or Server instantly closing connection

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,684
    Thanks
    25
    Thanked 333 Times in 309 Posts

    Default Interesting Problem - Host or Server instantly closing connection

    I have a rather interesting problem. I'm looking more for guesses at what is happening, than a solution.

    Here is a quick overview for reference:
    So I have an applet embedded on a website. The runtime data comes from files on the same server (which is a free host) as the website. I have one section of code which reads a server directory and parses for a list of files in the directory. To connect to the directory, I am using URLConnection and a BufferedReader (which I send a InputStreamReader to), and I connect via FTP (instead of usual URL) due to server related restrictions. I then have other sections of code that uses the same basic principle to read files (instead of a directory listing).

    Now, my problem is ONLY with the directory listing part. The rest of the file reading works perfectly (as far as I know). Here is where it gets interesting: my problem seems to be specific to only certain machines. I've attempted to run the program on 3 separate machines, 2 of which worked, and the other one failed, throwing a java.net.SocketException: Connection Reset. I've attempted to pinpoint the problem, but the more variables I take into account, the further I seem get from the answer. Here are my test cases:
    Computer 1: Windows 7, Firefox 3.6, Network A, Virus Protection A
    Computer 2: Windows 7, Firefox 12 (no addons), Internet Explorer 9 (no addons), Network A, Virus Protection A
    Computer 3: Windows 7, Firefox 12 (no addons), Internet Explorer 9 (no addons), Network B, Virus Protection B

    Now, Computer 1 and 3 work perfectly. Computer 1 and Computer 2 are on the same network (while Computer 3 is in an entirely different county), so I've ruled out the network. Computer 2 fails on all of its browsers (Firefox, Chrome, and Internet Explorer). However I've ruled out browser conflicts due to Computer 3. All 3 computers run the same operating system, so I've ruled that out. And Computer 1 and Computer 2 have the same Virus Protection program, so I can rule that out. It is clearly something specific to Computer 2, but I have no clue what it could be.

    I've pretty much ran out of variables here. Does anyone have any ideas for why one computer would throw a SocketException, while others wouldn't? Or can anyone think of any more variables I can rule out?
    Last edited by aussiemcgr; May 21st, 2012 at 09:30 PM.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,332
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: Interesting Problem - Host or Server instantly closing connection

    While I can only guess at what's wrong, I will point out an alternative - presuming computer 2 is capable of reading a webpage URL. Write a dynamic webpage which acts as an intermediary that prints out the files and directory. I say this for 2 reasons: 1) unless you've truly obfuscated the code of your applet, someone with bad intentions could de-compile the applet, which gives them access access to your ftp user/pass allowing them to do whatever they wish on the server. Doing it through an intermediate webpage would be more secure/ 2) It would remove the need for FTP access, which could be the foundation of your problem.

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,684
    Thanks
    25
    Thanked 333 Times in 309 Posts

    Default Re: Interesting Problem - Host or Server instantly closing connection

    The problem I can foresee with that method is that the User reads and writes to the files on the server, so FTP is important for making the changes to the files.

    I am printing out the directory listing because I am unsure how many files will be in the directory, and what their names will be, at runtime. I have thought about having an intermediate file that simply has a list of the files in the directory, but that would leave open the possibility of a user corrupting that file (perhaps through users overwriting one another) and preventing all the rest of the users from finding their files.

    Also, how would a dynamic webpage react when many users request data all at once? It is very common for the program to parse a data file to look for a specific line, as some of these data files are over 2 gigs in size and doing a full read of the entire file would take way too long.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,332
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: Interesting Problem - Host or Server instantly closing connection

    Quote Originally Posted by aussiemcgr View Post
    The problem I can foresee with that method is that the User reads and writes to the files on the server, so FTP is important for making the changes to the files.

    I am printing out the directory listing because I am unsure how many files will be in the directory, and what their names will be, at runtime. I have thought about having an intermediate file that simply has a list of the files in the directory, but that would leave open the possibility of a user corrupting that file (perhaps through users overwriting one another) and preventing all the rest of the users from finding their files.

    Also, how would a dynamic webpage react when many users request data all at once? It is very common for the program to parse a data file to look for a specific line, as some of these data files are over 2 gigs in size and doing a full read of the entire file would take way too long.

    I'd worry more about FTP than see it as an advantage (for the same reason above). Just my .02 though. Everything you need can be done by wrapping the OS with some dynamic pages, or better yet writing an application server...its daunting and can be a lot of work, and depending upon your server might require using a language other than java. All this being said my posts didn't address your original question, but hopefully gave some insight into an alternative that you can choose to follow if you wish.

Similar Threads

  1. Replies: 0
    Last Post: May 10th, 2011, 07:02 AM
  2. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  3. Replies: 0
    Last Post: February 24th, 2011, 05:31 AM
  4. Replies: 3
    Last Post: January 5th, 2011, 07:12 AM
  5. problem with closing connection to client socket
    By sunitha in forum Java Networking
    Replies: 1
    Last Post: December 11th, 2010, 03:28 AM